Tcl Source Code

Artifact [85f0c870cb]
Login

Artifact 85f0c870cb2a630135524d84a757a33a3160a68e:

Attachment "pipe_cloexec.patch" to ticket [2417695fff] added by ferrieux 2008-12-12 21:32:41.
Index: unix/tclUnixNotfy.c
===================================================================
RCS file: /cvsroot/tcl/tcl/unix/tclUnixNotfy.c,v
retrieving revision 1.37
diff -u -r1.37 tclUnixNotfy.c
--- unix/tclUnixNotfy.c	26 Oct 2008 12:45:04 -0000	1.37
+++ unix/tclUnixNotfy.c	12 Dec 2008 14:30:35 -0000
@@ -937,6 +937,12 @@
     if (TclUnixSetBlockingMode(fds[1], TCL_MODE_NONBLOCKING) < 0) {
 	Tcl_Panic("NotifierThreadProc: could not make trigger pipe non blocking");
     }
+    if (fcntl(receivePipe, F_SETFD, FD_CLOEXEC) < 0) {
+	Tcl_Panic("NotifierThreadProc: could not make receive pipe close-on-exec");
+    }
+    if (fcntl(fds[1], F_SETFD, FD_CLOEXEC) < 0) {
+	Tcl_Panic("NotifierThreadProc: could not make trigger pipe close-on-exec");
+    }
 
     /*
      * Install the write end of the pipe into the global variable.
Index: unix/tclUnixPipe.c
===================================================================
RCS file: /cvsroot/tcl/tcl/unix/tclUnixPipe.c,v
retrieving revision 1.44
diff -u -r1.44 tclUnixPipe.c
--- unix/tclUnixPipe.c	21 Jul 2008 21:46:47 -0000	1.44
+++ unix/tclUnixPipe.c	12 Dec 2008 14:30:35 -0000
@@ -798,6 +798,9 @@
 	return TCL_ERROR;
     }
 
+    fcntl(fileNums[0], F_SETFD, FD_CLOEXEC);
+    fcntl(fileNums[1], F_SETFD, FD_CLOEXEC);
+
     *rchan = Tcl_MakeFileChannel((ClientData) INT2PTR(fileNums[0]),
 	    TCL_READABLE);
     Tcl_RegisterChannel(interp, *rchan);