caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Markus E L <ls-ocaml-2006@m-e-leypold.de>
To: caml-list@inria.fr
Subject: Re: [Caml-list] Closing all open file descriptors
Date: Sat, 15 Sep 2007 16:27:54 +0200	[thread overview]
Message-ID: <ozfy1g9f6d.fsf@hod.lan.m-e-leypold.de> (raw)
In-Reply-To: <1189857437.46ebc89defff3@webmail.in-berlin.de> (Oliver Bandel's message of "Sat, 15 Sep 2007 13:57:17 +0200")


Oliver Bandel wrote:

> 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?

No.

> In C, there is a function fileno(3).
> Possibly this is, what people discussing
> in this thread are looking for.

No. You're barking up the completely wrong tree. We are looking for a
way to iterate over ALL open filedescriptors, wether inherited from
the parent process (which we don't control / haven't written
ourselves, so no recurrence to set_closeon_exec), or opened by a
library procedure or opened by our own program.

> This would be a thing that could be included in
> Ocaml, but the result would not be an integer-value,

Bah. Nobody asked for integer values.

> because OCaml uses abstract types for file descriptors.

Yes, yes, we know.

> 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, 

But you _have_ to do it, how else could you do buffered IO on sockets?

> and so in OCaml, which is quite more
> high-level stuff, I would be even more sceptical on mixing
> these things together.

No, it's very similar to the relationship between stdio and unix file
descriptors.

> As a general rule I would recommend, not to mix the different
> IO-possibilities.

It's not so rare that you would have to do a select() on some I/O
channel you'd on the other side rather prefer to do buffered I/O with
instead of writing (again) your own buffering. Fortunately this
works. 

So I rate "I would not recommend" rather too strong. It works and it
is AFAI understand guaranteed to work. One just has to be prepared to
understand the interaction between buffered and unbuffered I/O, which
are a _little_ bit more complex than one type of I/O alone, but --
nonetheless -- managable.

Regards -- Markus


  reply	other threads:[~2007-09-15 14:22 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-09-13 22:56 Dave Benjamin
2007-09-14  1:04 ` [Caml-list] " Erik de Castro Lopo
2007-09-14  6:35   ` Dave Benjamin
2007-09-14  6:48     ` Erik de Castro Lopo
2007-09-14  7:32       ` Dave Benjamin
2007-09-14  6:33 ` David Allsopp
2007-09-14  6:41   ` Dave Benjamin
2007-09-14 10:54     ` Andre Nathan
2007-09-14 10:00   ` Mattias Engdegård
2007-09-14 20:31     ` Dave Benjamin
2007-09-14 21:52       ` Oliver Bandel
2007-09-14 22:12         ` Markus E L
2007-09-15  9:15           ` Oliver Bandel
2007-09-15  9:26             ` Erik de Castro Lopo
2007-09-15 10:43               ` Oliver Bandel
2007-09-15 11:36                 ` Mattias Engdegård
2007-09-15 11:57                   ` Oliver Bandel
2007-09-15 14:27                     ` Markus E L [this message]
2007-09-15 12:16                   ` Oliver Bandel
2007-09-15 14:29                     ` Markus E L
2007-09-15 18:04                       ` skaller
2007-09-15 14:17                   ` Markus E L
2007-09-15 14:16                 ` Markus E L
2007-09-15 15:58                   ` Eric Cooper
2007-09-15 16:17                     ` Markus E L
2007-09-15 18:33                       ` skaller
2007-09-15 17:44                   ` skaller
2007-09-14 10:10 ` Gerd Stolpmann
2007-09-14 11:56 ` Oliver Bandel
2007-09-17 11:00 ` Ville-Pertti Keinonen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ozfy1g9f6d.fsf@hod.lan.m-e-leypold.de \
    --to=ls-ocaml-2006@m-e-leypold.de \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).