summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGurusamy Sarathy <gsar@cpan.org>1998-11-08 02:52:52 +0000
committerGurusamy Sarathy <gsar@cpan.org>1998-11-08 02:52:52 +0000
commitb0014e5ac00850569bd66e36e89520b1314a647f (patch)
treed7dbd29220af60de0b50dec1fcdfed3ada62e856
parente63a07aa01fbea927c64d4bc9f16cdc3e55c7b78 (diff)
downloadperl-b0014e5ac00850569bd66e36e89520b1314a647f.tar.gz
set close-on-exec bit on pipe() FDs
p4raw-id: //depot/perl@2215
-rw-r--r--pod/perlfunc.pod8
-rw-r--r--pod/perlvar.pod2
-rw-r--r--pp_sys.c5
3 files changed, 12 insertions, 3 deletions
diff --git a/pod/perlfunc.pod b/pod/perlfunc.pod
index e72624faa0..5a9543ff45 100644
--- a/pod/perlfunc.pod
+++ b/pod/perlfunc.pod
@@ -2394,7 +2394,9 @@ See L<perlipc/"Safe Pipe Opens"> 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<perlvar/$^F>.
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<IPC::Open2>, L<IPC::Open3>, and L<perlipc/"Bidirectional Communication">
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<perlvar/$^F>.
+
=item pop ARRAY
=item pop
diff --git a/pod/perlvar.pod b/pod/perlvar.pod
index af5f62f74b..38fd1684ee 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 7ae628bfb2..96ecd5875c 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: