diff options
author | Gurusamy Sarathy <gsar@cpan.org> | 2000-02-19 07:42:12 +0000 |
---|---|---|
committer | Gurusamy Sarathy <gsar@cpan.org> | 2000-02-19 07:42:12 +0000 |
commit | 8d2a6795a8433e9623ccf677a19bf470170549e9 (patch) | |
tree | f789cca7748a36e23793a7383a34bb79824a9f82 /pp_sys.c | |
parent | aa6ffa1650ac66b040000b508f9d85569d9fe839 (diff) | |
download | perl-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.c | 10 |
1 files changed, 10 insertions, 0 deletions
@@ -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; |