Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

How do I close a file descriptor by number?

by faq_monk (Initiate)
on Oct 13, 1999 at 03:42 UTC ( #816=perlfaq nodetype: print w/replies, xml ) Need Help??

Current Perl documentation can be found at perldoc.perl.org.

Here is our local, out-dated (pre-5.6) version:

This should rarely be necessary, as the Perl close() function is to be used for things that Perl opened itself, even if it was a dup of a numeric descriptor, as with MHCONTEXT above. But if you really have to, you may be able to do this:

    require 'sys/syscall.ph';
    $rc = syscall(&SYS_close, $fd + 0);  # must force numeric
    die "can't sysclose $fd: $!" unless $rc == -1;

Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
[marto]: "My solution is I just don’t use these tools anymore".
[ambrus]: Corion: Maybe I'm not explaining the situation clearly enough, maybe I'm just wrong and he's right and we can compute that data,
[ambrus]: but hopefully he just wants to think it through himself his way and understand why it's impossible rather than blindly accept my argument.
choroba quickly peeps in from a café
[1nickt]: Good morning Monks of the world!
[Corion]: ambrus: Yeah, hopefully it's that
[1nickt]: I am stumped, maybe someone brainy can clear my mind?

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (10)
As of 2017-12-12 13:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What programming language do you hate the most?




















    Results (332 votes). Check out past polls.

    Notices?