From: Robert Klemme Date: 2004-08-25T05:05:41+09:00 Subject: Re: Find the number of open files "Charles Mills" schrieb im Newsbeitrag news:267B9838-F607-11D8-93A8-000A95A27A10@freeshell.org... > On Aug 24, 2004, at 12:41 PM, Charles Mills wrote: > > > Is there an easy way to find out the number of open files held by a > > process (using C or Ruby)? > > > I think the way I phrased the question above makes the problem sound > harder than it is... > I am unittesting a C extension. The extension opens files using > open(). I want to make sure that the extension closes all the files it > opens (when errors occur or whatever). > > So I figured getting a count of open file descriptors before the > extension code is called and after it is finished would enable me to do > this. IMHO this would not be safe unless you disable threading: another thread could open or close files in the meantime. Why don't you just create a customized class that does the bookkeeping? Alternatively you could hand in open IO objects, if the logic of your extension allows this. Kind regards robert