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: Oliver Bandel <oliver@f...>
Subject: Re: [Caml-list] Closing all open file descriptors
Zitat von Mattias EngdegÄ   rd <mattias@virtutech.se>:

> >If you have all your open descriptors in a list,
> >you can close them after a fork.
>
> That approach does not compose well --- descriptors opened by
> a library will be excluded. The only good way is to ask the system.
>


What do you mean with "does not compose well"?
Do you see OCaml-specific problems here, or what?
In C, there is a function fileno(3).
Possibly this is, what people discussing
in this thread are looking for.

This would be a thing that could be included in
Ocaml, but the result would not be an integer-value,
because OCaml uses abstract types for file descriptors.
And to have buffered-io streams together with
abstract file descriptor-types and additionally having a
integer-aequivalent of it, IMHO would be an emerging mess.


When it is intended to make low-level handling
of things with the Unix-functions, one would use
Unix.open and not open_in or open_out, IMHO.
And then the file-descriptors are already available.

I'm a littlebid sceptical on using high-level and low-level
stuff together. In C it's also not recommended to mix buffered
and non-buffered IO, and so in OCaml, which is quite more
high-level stuff, I would be even more sceptical on mixing
these things together.

As a general rule I would recommend, not to mix
the different IO-possibilities.
And that's a reason, why C-functions like fileno(3)
are rarely used by myself.

Ciao,
   Oliver