From: Bruno.Verlyck@inria.fr
To: basile.starynkevitch@cea.fr
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Unix subdaemon, channels, filedescriptors....
Date: Wed, 17 Jul 2002 18:05:22 +0200 [thread overview]
Message-ID: <200207171605.g6HG5M928479@waco.inria.fr> (raw)
In-Reply-To: <15669.31207.415691.386109@is002254.saclay.cea.fr> (basile.starynkevitch@cea.fr)
Date: Wed, 17 Jul 2002 16:06:31 +0200
From: Basile STARYNKEVITCH <basile.starynkevitch@cea.fr>
I would like to close all the filedescriptors after the fork.
This is what set_close_on_exec is for, except it's after the exec.
Is it enough ? (You wrote `it fork and execs processes').
Unfortunately, the caml_out_channels_list primitive (coded in C in
ocaml/byterun/io.c), which is used in stdlib/pervasives.ml is not
published in pervasives.mli, and there is no caml_in_channels_list
primitive
May I suggest publishing this primitive in the future ocaml v3.05?
Do you mean: these two primitives ?
BTW, all this stuff was added to support Cash (now you know what is my
next suggestion :-). Since flush_all was considered of general
interest, caml_out_channels_list was integrated to the main sources to
implement it. Had flush_all not been added to Pervasives, it would
have stayed in the C part of Cash. So to get caml_out_channels_list
right now, an external declaration is enough. For
caml_in_channels_list, 20 lines of C will do (1).
Also, Unix.open_process_in and related seems to forget closing the file
descriptors in the child process,
[..]
How do I close (in Ocaml) every channel except stdin, stdout, stderr?
In the next version (and in the CVS sources), every channel opened by
Pervasives is marked by set_close_on_exec, so this problem should go
away.
Bruno.
(1) At first sight, copy caml_out_channels_list, and replace
if (channel->max == NULL) {
by
if (channel->max != NULL && channel->fd >= 0) {
(Untested).
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
next prev parent reply other threads:[~2002-07-17 16:05 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-07-17 14:06 Basile STARYNKEVITCH
2002-07-17 16:05 ` Bruno.Verlyck [this message]
2002-07-19 13:08 ` Xavier Leroy
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=200207171605.g6HG5M928479@waco.inria.fr \
--to=bruno.verlyck@inria.fr \
--cc=basile.starynkevitch@cea.fr \
--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