Browse thread
Closing all open file descriptors
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Oliver Bandel <oliver@f...> |
| Subject: | Re: [Caml-list] Closing all open file descriptors |
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. But if you like the concept of completely using files, Plan9 as operating system would make sense to you. :) > but at least you don't have a bunch of unnecessary system calls or > a hard-coded maximum Something like Sys.max_open_fd would be fine, and I think there should be a way to make it cross-platform-available. > (assuming getrlimit is unavailable, as it is with > OCaml currently). getrlimit seems to be a Unix-only thing. I don't know if this is also available on other systems, like Windows or so. So, if it is Unix-specific, this only would make sense in the Unix-modlue. But something like the maximum number of open files / max-num of used filedescriptors would also make sense on unix. So, I would ask for something like a Sys.max_open_fd. This owuld be a cross-platform thing. > I wonder if /dev/fd is more or less portable... Will this be available on non-Unix and non-Linux systems? You also mentioned Win-systems? If you also need that portability, you should not look for Unix-only features. Ciao, Oliver