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



Drazen Kacar wrote:
> Since I don't have the latest zsh development source tree, could you
> integrate this one in:
> 
> #ifdef TIOCNXCL
> if(open("dev/tty", O_RDWR) < 0 && errno == EBUSY)
>    ioctl(0, TIOCNXCL, 0);
> #endif
> 
> That will unlock terminal device (at least on Solaris) and something
> should really do that (preferrably the shell). TIOCNXCL is defined in
> termios.h.

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.

--- Src/init.c.tiocnxcl	Sat Jan 30 13:29:37 1999
+++ Src/init.c	Sat Jan 30 13:42:31 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) < 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));




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