develooper Front page | perl.perl5.porters | Postings from January 2011

Re: fcntl() and FD_CLOEXEC

Thread Previous | Thread Next
From:
Bo Lindbergh
Date:
January 30, 2011 05:30
Subject:
Re: fcntl() and FD_CLOEXEC
Message ID:
82237A81-FA05-4693-A1B2-6C71BE09C1D9@stacken.kth.se
Quoth NormW:
> diff -Nur mirrors-perl-730d722.orig/doio.c mirrors-perl-730d722/doio.c
> --- mirrors-perl-730d722.orig/doio.c	2011-01-30 20:45:45.062500000 +1100
> +++ mirrors-perl-730d722/doio.c	2011-01-30 20:42:23.125000000 +1100
> @@ -644,15 +644,11 @@
>                 /* need to close fp without closing underlying fd */
>                 int ofd = PerlIO_fileno(fp);
>                 int dupfd = PerlLIO_dup(ofd);
> -#if defined(HAS_FCNTL) && defined(F_SETFD)
> -		/* Assume if we have F_SETFD we have F_GETFD */
> -                int coe = fcntl(ofd,F_GETFD);
> -#endif
>                 PerlIO_close(fp);
>                 PerlLIO_dup2(dupfd,ofd);
> #if defined(HAS_FCNTL) && defined(F_SETFD)
> 		/* The dup trick has lost close-on-exec on ofd */
> -		fcntl(ofd,F_SETFD, coe);
> +		fcntl(ofd, F_SETFD, FD_CLOEXEC);
> #endif
>                 PerlLIO_close(dupfd);
> 	    }

Why did you change saving and restoring the close-on-exec flag
to unconditionally setting it?


/Bo Lindbergh


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About