Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!cs.utexas.edu!ut-emx!perv.pe.utexas.edu!pefv700 From: pefv700@perv.pe.utexas.edu Newsgroups: comp.unix.programmer Subject: running out of file descriptors Message-ID: <41618@ut-emx.uucp> Date: 18 Dec 90 22:03:54 GMT Sender: news@ut-emx.uucp Distribution: usa Organization: Dept. of Petroleum Engineering, The University of Texas at Aust Lines: 18 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