summaryrefslogtreecommitdiff
path: root/toke.c
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>2015-08-26 08:55:37 -0400
committerJarkko Hietaniemi <jhi@iki.fi>2015-08-26 11:40:40 -0400
commit131d45a96c910d0fe46597ab156a35837879bf9c (patch)
tree0fca2751032d5ac423fae4e625eab7cce08386ec /toke.c
parent5798d63101f7b13bd5aaf5a5bf429a8e08991016 (diff)
downloadperl-131d45a96c910d0fe46597ab156a35837879bf9c.tar.gz
Explicitly use and check for FD_CLOEXEC.
This may break places which have the FD_CLOEXEC functionality but do not have the FD_CLOEXEC define. In any case, using a boolean for the F_SETFD flag is icky. Using an explicit 1 is also dubious.
Diffstat (limited to 'toke.c')
-rw-r--r--toke.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/toke.c b/toke.c
index 7a0f1b6c55..d30bfe69da 100644
--- a/toke.c
+++ b/toke.c
@@ -7039,10 +7039,12 @@ Perl_yylex(pTHX)
if (!GvIO(gv))
GvIOp(gv) = newIO();
IoIFP(GvIOp(gv)) = PL_rsfp;
-#if defined(HAS_FCNTL) && defined(F_SETFD)
+#if defined(HAS_FCNTL) && defined(F_SETFD) && defined(FD_CLOEXEC)
{
const int fd = PerlIO_fileno(PL_rsfp);
- fcntl(fd,F_SETFD,fd >= 3);
+ if (fd >= 3) {
+ fcntl(fd,F_SETFD, FD_CLOEXEC);
+ }
}
#endif
/* Mark this internal pseudo-handle as clean */