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: 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.

Dave