Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

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

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/';
    $rc = syscall(&SYS_close, $fd + 0);  # must force numeric
    die "can't sysclose $fd: $!" unless $rc == -1;

Log In?

What's my password?
Create A New User
[Discipulus]: good morning nuns and monks, even if rainy
[choroba]: Snow here. Good morning nonetheless.
[Corion]: A good morning to you too, Discipulus!

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (7)
As of 2018-03-19 08:00 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (236 votes). Check out past polls.