summaryrefslogtreecommitdiff
path: root/pp_sys.c
diff options
context:
space:
mode:
authorGurusamy Sarathy <gsar@cpan.org>2000-02-19 07:42:12 +0000
committerGurusamy Sarathy <gsar@cpan.org>2000-02-19 07:42:12 +0000
commit8d2a6795a8433e9623ccf677a19bf470170549e9 (patch)
treef789cca7748a36e23793a7383a34bb79824a9f82 /pp_sys.c
parentaa6ffa1650ac66b040000b508f9d85569d9fe839 (diff)
downloadperl-8d2a6795a8433e9623ccf677a19bf470170549e9.tar.gz
set close-on-exec flag on sockets too, like we do for files
and pipes p4raw-id: //depot/perl@5137
Diffstat (limited to 'pp_sys.c')
-rw-r--r--pp_sys.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/pp_sys.c b/pp_sys.c
index a9292a1c83..18edf7ad65 100644
--- a/pp_sys.c
+++ b/pp_sys.c
@@ -2042,6 +2042,9 @@ PP(pp_socket)
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
@@ -2092,6 +2095,10 @@ PP(pp_sockpair)
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
@@ -2254,6 +2261,9 @@ PP(pp_accept)
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;