<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE message PUBLIC
  "-//MLarc//DTD MLarc output files//EN"
  "../../mlarc.dtd"[
  <!ATTLIST message
    listname CDATA #REQUIRED
    title CDATA #REQUIRED
  >
]>

  <?xml-stylesheet href="../../mlarc.xsl" type="text/xsl"?>


<message 
  url="2002/07/6df64d244fa3841b6464fe19614fa87c"
  from="Bruno.Verlyck@i..."
  author="Bruno.Verlyck@i..."
  date="2002-07-17T16:05:24"
  subject="Re: [Caml-list] Unix subdaemon, channels, filedescriptors...."
  prev="2002/07/6f9d163bb49127c0bf96895d22c05290"
  next="2002/07/fe9646fa169c9ecb8e15a547bbb95c87"
  prev-in-thread="2002/07/6f9d163bb49127c0bf96895d22c05290"
  next-in-thread="2002/07/85bf00d0b31dc09005c79719c1be9ec6"
  prev-thread="2002/07/e97792a8a64614e000b7a7096a57651b"
  next-thread="2002/07/fe9646fa169c9ecb8e15a547bbb95c87"
  root="../../"
  period="month"
  listname="caml-list"
  title="Archives of the Caml mailing list">

<thread subject="[Caml-list] Unix subdaemon, channels, filedescriptors....">
<msg 
  url="2002/07/6f9d163bb49127c0bf96895d22c05290"
  from="Basile STARYNKEVITCH &lt;basile.starynkevitch@c...&gt;"
  author="Basile STARYNKEVITCH"
  date="2002-07-17T14:07:25"
  subject="[Caml-list] Unix subdaemon, channels, filedescriptors....">
<msg 
  url="2002/07/6df64d244fa3841b6464fe19614fa87c"
  from="Bruno.Verlyck@i..."
  author="Bruno.Verlyck@i..."
  date="2002-07-17T16:05:24"
  subject="Re: [Caml-list] Unix subdaemon, channels, filedescriptors....">
</msg>
<msg 
  url="2002/07/85bf00d0b31dc09005c79719c1be9ec6"
  from="Xavier Leroy &lt;xavier.leroy@i...&gt;"
  author="Xavier Leroy"
  date="2002-07-19T13:08:12"
  subject="Re: [Caml-list] Unix subdaemon, channels, filedescriptors....">
</msg>
</msg>
</thread>

<contents>
   Date: Wed, 17 Jul 2002 16:06:31 +0200
   From: Basile STARYNKEVITCH &lt;basile.starynkevitch@cea.fr&gt;

   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-&gt;max == NULL) {
by
    if (channel-&gt;max != NULL &amp;&amp; channel-&gt;fd &gt;= 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

</contents>

</message>

