Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > how to see how many open file descriptors my program has?

Reply
Thread Tools

how to see how many open file descriptors my program has?

 
 
Rex Gustavus Adolphus
Guest
Posts: n/a
 
      03-04-2004
This question is about a pre-5.6-perl


I have a problem with a deamon-program I've written that after a
couple of days/weeks runs out of file descriptors.

I wonder if there is a command
to see how many open file descriptors my program has?

And is there a command
to see how many open file descriptors the system has?

I am not opening them explicitly,
I think they are being opened by
glob() and/or File::Copy::move
(the deamon is polling for certain files, and when found
moves them between NFS-mounted filesystems)

tia
/RGA
 
Reply With Quote
 
 
 
 
pkent
Guest
Posts: n/a
 
      03-06-2004
In article <(E-Mail Removed)> ,
http://www.velocityreviews.com/forums/(E-Mail Removed) (Rex Gustavus Adolphus) wrote:

> I have a problem with a deamon-program I've written that after a
> couple of days/weeks runs out of file descriptors.
>
> I wonder if there is a command
> to see how many open file descriptors my program has?
>
> And is there a command
> to see how many open file descriptors the system has?


The ulimit command might be of use in raising the limit, although that
doesn't really solve the problem.

> I am not opening them explicitly,
> I think they are being opened by
> glob() and/or File::Copy::move


Interesting - I'd have thought that these wouldn't leak filehandles...
One thing that I've seen is where someone used an opendir() to open a
directory and then they did close() on that handle, not closedir(). Soon
the program ran out of directory handles.

Grep through your code for any occurence of 'open' or creating a new
Filehandle object of some kind. In long-running processes like your
daemon you should probably keep the scope of filehandle objects as tight
as possible, maybe localise normal file/directory handles, and ensure
that you close handles as soon as you possibly can.

The /proc filesystem mentioned by zentara is common but not available on
all systems - just something to watch out for. The handy thing about the
links in fd is that they point, on my system anyway, to the actual
filenames, so if I do 'ls -lab' in that directory I can see what files
are open.

P

--
pkent 77 at yahoo dot, er... what's the last bit, oh yes, com
Remove the tea to reply
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Capture file descriptors while running an external program jfigueiras@sapo.pt Python 0 11-22-2006 12:40 PM
find max number of open file descriptors using java puzzlecracker Java 8 09-07-2006 01:54 PM
syncronizing between two file descriptors open on the same file JG C Programming 5 02-08-2005 01:25 PM
closing all open file descriptors Ara.T.Howard Ruby 3 09-15-2004 06:21 PM



Advertisments