I have a program that quits after a time with "too many open files". How can I trace which files are opened and closed? I know I can set this limit a higher value, but that would only defer the problem.
I remember using a program like dtruss or dtrace for that purpose but I can't remember how I invoked it and --help
gave to much confusion.
I run that program with a wrapper script based on nodejs, so I need to follow the child processes.
Question: what is the best strategy to find out which files (descriptors) are opened and which are closed?
Best Answer
lsof will show you the open file handles.
If you know the PID use the
-p
flag.Eg, on my zsh shell at the moment I see:
The Type column shows the various file or pseudo file types that might be open, sockets, pipes, etc.
ulimit or limit, depending on system and shell lets you change the number of open files.