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

PATCH: FD_CLOEXEC



I was thinking about the command substitution problem and keeping file
descriptors open when I checked up on the use of the close-on-exec flag in
zftp.c, which is the only place it's used (could we do with some more?)
I noticed I was using it with pointers instead of integers; goodness knows
why, except there's no type checking on that argument.  I confirmed by
experiment on Solaris that it wants the actual integer (easy to test, since
FD_CLOEXEC is 1 and pointers are even).

I developed zftp under AIX, so it's just possible something funny is going
on there.  Maybe Oliver could check it at least compiles?

Index: Src/Modules/zftp.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Modules/zftp.c,v
retrieving revision 1.3
diff -u -r1.3 zftp.c
--- Src/Modules/zftp.c	2000/05/09 17:49:30	1.3
+++ Src/Modules/zftp.c	2000/05/25 09:41:43
@@ -1303,8 +1303,7 @@
 #endif
 #if defined(F_SETFD) && defined(FD_CLOEXEC)
 	/* If the shell execs a program, we don't want this fd left open. */
-	len = FD_CLOEXEC;
-	fcntl(zfsess->dfd, F_SETFD, &len);
+	fcntl(zfsess->dfd, F_SETFD, FD_CLOEXEC);
 #endif
 
     return 0;
@@ -1988,8 +1987,7 @@
 
 #if defined(F_SETFD) && defined(FD_CLOEXEC)
     /* If the shell execs a program, we don't want this fd left open. */
-    len = FD_CLOEXEC;
-    fcntl(zfsess->cfd, F_SETFD, &len);
+    fcntl(zfsess->cfd, F_SETFD, FD_CLOEXEC);
 #endif
 
     len = sizeof(zfsess->sock);
@@ -2057,8 +2055,7 @@
 	DPUTS(zfstatfd == -1, "zfstatfd not created");
 #if defined(F_SETFD) && defined(FD_CLOEXEC)
 	/* If the shell execs a program, we don't want this fd left open. */
-	len = FD_CLOEXEC;
-	fcntl(zfstatfd, F_SETFD, &len);
+	fcntl(zfstatfd, F_SETFD, FD_CLOEXEC);
 #endif
 	unlink(fname);
     }



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