Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

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: 2007-09-14 (06:42)
From: Dave Benjamin <dave@r...>
Subject: Re: [Caml-list] Closing all open file descriptors
David Allsopp 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.

Yes, I assumed that this would be non-portable, and that is yet another 
problem. It seems that dropping down to C is the only way to really do 
this right.

> Wouldn't an easier, portable way be to wrap Unix.openfile and Unix.close to
> maintain a set of open file_descrs or is your concern the risk of files left
> open by third party code?

The latter. The simple solution is to use Unix.set_close_on_exec from 
the parent process, but that only works if it's under my control.