ulimit -a tells me I have a limit of 1024 open files, which is the default on my distro. Is there a way to show how many of these are currently used, or how many are remaining?

link|improve this question
feedback

1 Answer

up vote 4 down vote accepted

This limit apply per process.

One way to get the number of open files per process would be on Linux or Solaris:

for i in /proc/*/fd
do
    [ -r $i ] && printf "%6d : %d\n" $(basename $(dirname $i)) $(ls $i | wc -l)
done
link|improve this answer
If I start a shell, isn't this limit inherited to all child processes which I do further start from this shell? – drhirsch May 11 '11 at 14:00
Or more exactly, is the number of the remaining open files inherited? – drhirsch May 11 '11 at 14:05
No. Each subprocess starts with the full number of available fds. What is inherited is that limit, which can be reduced (or raised if you have the privileges). – jlliagre May 11 '11 at 14:32
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.