From: Peter Stephenson <pws@ibmth.df.unipi.it>
To: zsh-workers@math.gatech.edu
Subject: PATCH: 3.1.5-pws-6: ttys revisited
Date: Wed, 03 Feb 1999 12:08:57 +0100 [thread overview]
Message-ID: <9902031108.AA50042@ibmth.df.unipi.it> (raw)
In-Reply-To: ""Bart Schaefer""'s message of "Sat, 30 Jan 1999 10:04:51 NFT." <990130100451.ZM12586@candle.brasslantern.com>
ioctl for non-exclusive tty use:
"Bart Schaefer" wrote:
> (For PWS et al.) Even if it should always be done, I think it'd be a good
> idea to move this code down the point where an attempt to open /dev/tty
> might be made anyway, so that it needn't be opened and closed more than
> once.
That seems to be sensible. This patch will do the whole thing pretty
cheaply: only the `if (SHTTY == -1 && errno == EBUSY)' is usually
executed.
--- Src/init.c.nxcl2 Mon Feb 1 15:28:02 1999
+++ Src/init.c Wed Feb 3 12:01:41 1999
@@ -301,22 +301,19 @@
/* Make sure the tty is opened read/write. */
if (isatty(0)) {
+ zsfree(ttystrname);
+ if ((ttystrname = ztrdup(ttyname(0)))) {
+ SHTTY = movefd(open(ttystrname, O_RDWR | O_NOCTTY));
#ifdef TIOCNXCL
- /*
- * See if the terminal claims to be busy. If so, and fd 0
- * is a terminal, try and set non-exclusive use for that.
- * This is something to do with Solaris over-cleverness.
- */
- int tmpfd;
- if ((tmpfd = open("/dev/tty", O_RDWR | O_NOCTTY)) < 0) {
- if (errno == EBUSY)
+ /*
+ * See if the terminal claims to be busy. If so, and fd 0
+ * is a terminal, try and set non-exclusive use for that.
+ * This is something to do with Solaris over-cleverness.
+ */
+ if (SHTTY == -1 && errno == EBUSY)
ioctl(0, TIOCNXCL, 0);
- } else
- close(tmpfd);
#endif
- zsfree(ttystrname);
- if ((ttystrname = ztrdup(ttyname(0))))
- SHTTY = movefd(open(ttystrname, O_RDWR | O_NOCTTY));
+ }
/*
* xterm, rxvt and probably all terminal emulators except
* dtterm on Solaris 2.6 & 7 have a bug. Applications are
--
Peter Stephenson <pws@ibmth.df.unipi.it> Tel: +39 050 844536
WWW: http://www.ifh.de/~pws/
Dipartimento di Fisica, Via Buonarroti 2, 56127 Pisa, Italy
next prev parent reply other threads:[~1999-02-03 11:08 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-01-27 22:26 strange xterm & zsh behaviour Drazen Kacar
1999-01-28 5:46 ` Bart Schaefer
1999-01-28 9:38 ` Drazen Kacar
1999-01-29 3:47 ` Drazen Kacar
1999-01-29 9:16 ` PATCH: 3.1.5* & 3.0.5: " Peter Stephenson
1999-01-29 18:59 ` PATCH: (more) " Bart Schaefer
1999-01-29 19:08 ` Bart Schaefer
1999-01-30 5:54 ` Drazen Kacar
1999-01-30 12:43 ` Peter Stephenson
1999-01-30 12:51 ` Peter Stephenson
1999-01-30 18:04 ` Bart Schaefer
1999-01-30 18:27 ` Drazen Kacar
1999-01-30 20:41 ` Terminal initialization and (non-)interactive shells Bart Schaefer
1999-02-01 0:50 ` Drazen Kacar
1999-02-01 1:24 ` Bart Schaefer
1999-02-03 11:08 ` Peter Stephenson [this message]
1999-01-30 13:29 ` PATCH: (more) Re: PATCH: 3.1.5* & 3.0.5: Re: strange xterm & zsh behaviour Drazen Kacar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=9902031108.AA50042@ibmth.df.unipi.it \
--to=pws@ibmth.df.unipi.it \
--cc=zsh-workers@math.gatech.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).