[OT] figuring out which files have F_CLOEXEC

Nicholas Clark nick at ccl4.org
Fri Mar 27 16:30:54 GMT 2009


Sorry for mentioning the four letter word, but I have a problem.

Without resorting to XS, Inline, or similar skulduggery, is there a way to
do the following:

  1: Work out which file descriptors have F_CLOEXEC set
  2: Close those that do

[without doing an exec :-)]

My problem seems to be that I

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.

and I can't see a way round this.

Nicholas Clark
  
 


More information about the london.pm mailing list