checkin
asked on
How many file open ?
Hi !
How can I find out how many file descriptors a process has open ? Either I can use a system call but preferrably I would like to put it in the program itself. I am on Sun Solaris machine.
Marvin.
How can I find out how many file descriptors a process has open ? Either I can use a system call but preferrably I would like to put it in the program itself. I am on Sun Solaris machine.
Marvin.
You could try scaning the __iob[] structure.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Sorry, ozo, I didn't see you already post a comment.
Also, to ozo, my understanding is, __iob[] only includes fds opened via fopen() , fdopen() and fdopen(). Other fds opened through open(), pipe(), dup(), socket(), accept(), etc.. are not included.
code correction:
the last code line in the proposed answer:
return count -3;
should change to:
if( pid == getpid() )
return count - 3;
else
return count -2;
the last code line in the proposed answer:
return count -3;
should change to:
if( pid == getpid() )
return count - 3;
else
return count -2;