Version française
Home     About     Download     Resources     Contact us    
Browse thread
Closing all open file descriptors
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Markus E L <ls-ocaml-2006@m...>
Subject: Re: [Caml-list] Closing all open file descriptors

Oliver Bandel wrote:

> Zitat von Dave Benjamin <dave@ramenlabs.com>:
>
>> On Fri, 14 Sep 2007, Mattias EngdegÄrd wrote:
>>
>> >> Probably irrelevant here, but this approach wouldn't work under Windows
>> >> (Unix.file_descr is the Win32 file handle at that point which is often
>> >> larger than 1024). More relevantly, Unix can be reconfigured to allow for
>> >> more than 1024 open files.
>> >
>> > I think platform-dependent code is required here. The common way of
>> > doing this under Linux (and Solaris, probably) is to readdir
>> > /proc/PID/fd/. Windows is of course very different.
>>
>> I like this approach. It doesn't eliminate the need to convert ints to
>> descrs,
>
> On Unix, file-descriptors are identified by integer-values.
>
> In OCaml, you have abstract types for file-descriptors.
> So, how to convert them? I think, officially there is no way.

By writing a C-function which does the conversion. This, of course
could only exist under Linux. 

Generally a function enumerate_my_open_files would not be such a bad
idea.

Regards -- Markus