From: Gurusamy Sarathy Date: Sun, 8 Nov 1998 02:52:52 +0000 (+0000) Subject: set close-on-exec bit on pipe() FDs X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=4771b018b5cdc984c08bd1fd014895ea804ec3f0;p=p5sagit%2Fp5-mst-13.2.git set close-on-exec bit on pipe() FDs p4raw-id: //depot/perl@2215 --- diff --git a/pod/perlfunc.pod b/pod/perlfunc.pod index e72624f..5a9543f 100644 --- a/pod/perlfunc.pod +++ b/pod/perlfunc.pod @@ -2394,7 +2394,9 @@ See L for more examples of this. NOTE: On any operation that may do a fork, any unflushed buffers remain unflushed in both processes, which means you may need to set C<$|> to -avoid duplicate output. +avoid duplicate output. On systems that support a close-on-exec flag on +files, the flag will be set for the newly opened file descriptor as +determined by the value of $^F. See L. Closing any piped filehandle causes the parent process to wait for the child to finish, and returns the status value in C<$?>. @@ -2614,6 +2616,10 @@ after each command, depending on the application. See L, L, and L for examples of such things. +On systems that support a close-on-exec flag on files, the flag will be set +for the newly opened file descriptors as determined by the value of $^F. +See L. + =item pop ARRAY =item pop diff --git a/pod/perlvar.pod b/pod/perlvar.pod index af5f62f..38fd168 100644 --- a/pod/perlvar.pod +++ b/pod/perlvar.pod @@ -667,7 +667,7 @@ descriptors are not. Also, during an open(), system file descriptors are preserved even if the open() fails. (Ordinary file descriptors are closed before the open() is attempted.) Note that the close-on-exec status of a file descriptor will be decided according to the value of -C<$^F> at the time of the open, not the time of the exec. +C<$^F> when the open() or pipe() was called, not the time of the exec(). =item $^H diff --git a/pp_sys.c b/pp_sys.c index 7ae628b..96ecd58 100644 --- a/pp_sys.c +++ b/pp_sys.c @@ -572,7 +572,10 @@ PP(pp_pipe_op) else PerlLIO_close(fd[1]); goto badexit; } - +#if defined(HAS_FCNTL) && defined(F_SETFD) + fcntl(fd[0],F_SETFD,fd[0] > PL_maxsysfd); /* ensure close-on-exec */ + fcntl(fd[1],F_SETFD,fd[1] > PL_maxsysfd); /* ensure close-on-exec */ +#endif RETPUSHYES; badexit: