Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: PATCH: (more) Re: PATCH: 3.1.5* & 3.0.5: Re: strange xterm & zsh behaviour



Peter Stephenson wrote:
> You mean something like the following?  I don't quite know how to test
> for this, since you can't be assured fd 0 is /dev/tty.  Maybe the
> ioctl() on its own is enough.

sorrysorry... this time I've tested it.  (I didn't realise I could on
AIX, but TIOCNXCL does exist after all.)  This replaces the one two
minutes ago.

--- Src/init.c.tiocnxcl	Sat Jan 30 13:29:37 1999
+++ Src/init.c	Sat Jan 30 13:49:09 1999
@@ -300,6 +300,19 @@
 
     /* Make sure the tty is opened read/write. */
     if (isatty(0)) {
+#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)
+		ioctl(0, TIOCNXCL, 0);
+	} else
+	    close(tmpfd);
+#endif
 	zsfree(ttystrname);
 	if ((ttystrname = ztrdup(ttyname(0))))
 	    SHTTY = movefd(open(ttystrname, O_RDWR | O_NOCTTY));

-- 
Peter Stephenson <pws@xxxxxxxxxxxxxxxxx>       Tel: +39 050 844536
WWW:  http://www.ifh.de/~pws/
Dipartimento di Fisica, Via Buonarroti 2, 56127 Pisa, Italy




Messages sorted by: Reverse Date, Date, Thread, Author