about summary refs log tree commit diff
path: root/Src/init.c
diff options
context:
space:
mode:
Diffstat (limited to 'Src/init.c')
-rw-r--r--Src/init.c28
1 files changed, 14 insertions, 14 deletions
diff --git a/Src/init.c b/Src/init.c
index 5e0a550dd..10013c52b 100644
--- a/Src/init.c
+++ b/Src/init.c
@@ -28,11 +28,12 @@
  */
 
 #include "zsh.mdh"
-#include "init.pro"
 
 #include "zshpaths.h"
 #include "zshxmods.h"
 
+#include "init.pro"
+
 /**/
 int noexitct = 0;
 
@@ -300,22 +301,19 @@ init_io(void)
 
     /* 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
@@ -936,6 +934,7 @@ noop_function_int(int nothing)
     /* do nothing */
 }
 
+/**/
 # ifdef UNLINKED_XMOD_zle
 
 /**/
@@ -947,6 +946,7 @@ autoload_zleread(char *lp, char *rp, int ha)
     return zleread(lp, rp, ha);
 }
 
+/**/
 # endif /* UNLINKED_XMOD_zle */
 
 /**/