[OT] figuring out which files have F_CLOEXEC

Peter Corlett abuse at cabal.org.uk
Fri Mar 27 16:41:28 GMT 2009


On Fri, Mar 27, 2009 at 04:30:54PM +0000, Nicholas Clark wrote:
[...]
> 1: Can't call fcntl to enquire about F_CLOEXEC without having a file handle.
> 2: Whilst I can create a Perl file handle from a number, to get a 
>    handle open on that numeric file descriptor, I
> 3: now have a file handle open which uses that very numeric file descriptor
> 4: so if it goes out of scope, or otherwise is closed, the numeric file
>    descriptor gets closed, come what may,
> 5: which isn't what I want, as I want to keep open files that have F_CLOEXEC
>    clear.

open() with ">&" does dup(2) under the hood. Without testing, I'd have
assumed that when the new filehandle is closed, it won't close the duped
file handle. I can't recall whether the close-on-exec flag is passed through
on duping though.



More information about the london.pm mailing list