the same effect as assigning C<undef> to the readonly value--it
throws an exception.
-=item Close-on-exec bit may be set on pipe() handles
+=item Close-on-exec bit may be set on pipe and socket handles
On systems that support a close-on-exec flag on filehandles, the
-flag will be set for any handles created by pipe(), if that is
-warranted by the value of $^F that may be in effect. Earlier
-versions neglected to set the flag for handles created with
-pipe(). See L<perlfunc/pipe> and L<perlvar/$^F>.
+flag will be set for any handles created by pipe(), socketpair(),
+socket(), and accept(), if that is warranted by the value of $^F
+that may be in effect. Earlier versions neglected to set the flag
+for handles created with these operators. See L<perlfunc/pipe>,
+L<perlfunc/socketpair>, L<perlfunc/socket>, L<perlfunc/accept>,
+and L<perlvar/$^F>.
=item Writing C<"$$1"> to mean C<"${$}1"> is unsupported
does. Returns the packed address if it succeeded, false otherwise.
See the example in L<perlipc/"Sockets: Client/Server Communication">.
+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>.
+
=item alarm SECONDS
=item alarm
to get the proper definitions imported. See the examples in
L<perlipc/"Sockets: Client/Server Communication">.
+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>.
+
=item socketpair SOCKET1,SOCKET2,DOMAIN,TYPE,PROTOCOL
Creates an unnamed pair of sockets in the specified domain, of the
for the system call of the same name. If unimplemented, yields a fatal
error. Returns true if successful.
+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>.
+
Some systems defined C<pipe> in terms of C<socketpair>, in which a call
to C<pipe(Rdr, Wtr)> is essentially:
preserved even if the open() fails. (Ordinary file descriptors are
closed before the open() is attempted.) The close-on-exec
status of a file descriptor will be decided according to the value of
-C<$^F> when the open() or pipe() was called, not the time of the exec().
+C<$^F> when the corresponding file, pipe, or socket was opened, not the
+time of the exec().
=item $^H
if (!IoIFP(io) && !IoOFP(io)) PerlLIO_close(fd);
RETPUSHUNDEF;
}
+#if defined(HAS_FCNTL) && defined(F_SETFD)
+ fcntl(fd, F_SETFD, fd > PL_maxsysfd); /* ensure close-on-exec */
+#endif
RETPUSHYES;
#else
if (!IoIFP(io2) && !IoOFP(io2)) PerlLIO_close(fd[1]);
RETPUSHUNDEF;
}
+#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;
#else
if (!IoIFP(nstio) && !IoOFP(nstio)) PerlLIO_close(fd);
goto badexit;
}
+#if defined(HAS_FCNTL) && defined(F_SETFD)
+ fcntl(fd, F_SETFD, fd > PL_maxsysfd); /* ensure close-on-exec */
+#endif
PUSHp((char *)&saddr, len);
RETURN;