Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: •Re: open file descriptors

by etcshadow (Priest)
on Dec 13, 2003 at 21:37 UTC ( #314557=note: print w/ replies, xml ) Need Help??


in reply to •Re: open file descriptors
in thread open file descriptors

Well, that has the builtin assumption that the max fileno is 100, which is probably good enough, usually, but it will lead to a really hard to debug problem, eventually. It's actually somewhat of a weakness of perl, I think, that there is no exposed system call to get all open file descriptors. Obvoiously you can deal with this if you compile perl properly, and just refer to the system call by number through syscall()... but still, this is sad.

This is additionally sad because of the behavior of perl's output buffers on fork() (leaving buffers unflushed), since the buffers are duped with the fork, but there is no means by which to systematically flush all buffers before fork(). However, as I understand it, the behavior on fork() is fixed in later versions of perl (I'm still on 5.005_03... but we're working on an upgrade plan to 5.8 soon)... so that's good at least.


------------
:Wq
Not an editor command: Wq


Comment on Re: •Re: open file descriptors
Select or Download Code
Re: Re: •Re: open file descriptors
by exussum0 (Vicar) on Dec 13, 2003 at 22:03 UTC
    Having something, a system call, that could count all open file handles would be in the same class of functions like flock: only compatable to a point. I've never heard of a function in unix to do that, but I know that procfs hints you in on what's going on w/ a process.

    Play that funky music white boy..
      Yeah, you're right... it's not a system call issue (with the flush on fork), but an issue with the fact that perl doesn't have a fflush() builtin which emulates the fflush() in unix... that is: having the ability to flush all fd's (not just individual named fd's).

      Anyway, because I remembered that issue wrong, I made the incorrect leap that there must be an unimplemented-in-perl system call to get all open fd's.

      Anyway, my bad. Thanks. Still, it seems like there ought to be a faster way to find all open fd's than iterating through all *possible* fileno's looking for ones that are open fd's. Oh, well.


      ------------
      :Wq
      Not an editor command: Wq
        Well, in linux, you can do something like find

        /proc/123/fd/ -type f | wc -l

        FreeBSD doesn't have fd and osx doesn't even have /proc :(


        Play that funky music white boy..

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://314557]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (8)
As of 2014-09-16 08:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite cookbook is:










    Results (158 votes), past polls