running out of file descriptors

pefv700 at perv.pe.utexas.edu pefv700 at perv.pe.utexas.edu
Wed Dec 19 09:03:54 AEST 1990


I am trying to write a version of ls(1).  My problem is running out of file
descriptors with the recursive option. (The program on pp. 181-184 of K&R2
suffers from this problem.)

Perhaps ls(1) closes open directory files after "remembering" all of the
subdirectories it found there.  This is what rm(1) seems to do (as tested 
using -ri).  If so, how can this be done efficiently while taking advantage
of the NOFILES file descriptors that you do have (without using malloc 
all over the place) ?

I have also tested recursive cp(1).  It seems to NOT close open directories
until it is finished with all of their subdirectories and hence crashes
after running out of file descriptors.

Thanks,

Chris Phillips



More information about the Comp.unix.programmer mailing list