From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id SAA01951; Wed, 17 Jul 2002 18:05:24 +0200 (MET DST) Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id SAA01950 for ; Wed, 17 Jul 2002 18:05:23 +0200 (MET DST) Received: from waco.inria.fr (waco.inria.fr [128.93.25.2]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id g6HG5Mf12728; Wed, 17 Jul 2002 18:05:22 +0200 (MET DST) Received: (from verlyck@localhost) by waco.inria.fr (8.11.1/8.11.1) id g6HG5M928479; Wed, 17 Jul 2002 18:05:22 +0200 Date: Wed, 17 Jul 2002 18:05:22 +0200 Message-Id: <200207171605.g6HG5M928479@waco.inria.fr> X-Authentication-Warning: waco.inria.fr: verlyck set sender to Bruno.Verlyck@inria.fr using -f To: basile.starynkevitch@cea.fr CC: caml-list@inria.fr In-reply-to: <15669.31207.415691.386109@is002254.saclay.cea.fr> (basile.starynkevitch@cea.fr) Subject: Re: [Caml-list] Unix subdaemon, channels, filedescriptors.... From: Bruno.Verlyck@inria.fr References: <15669.31207.415691.386109@is002254.saclay.cea.fr> Mime-Version: 1.0 (generated by tm-edit 7.106) Content-Type: text/plain; charset=US-ASCII Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Date: Wed, 17 Jul 2002 16:06:31 +0200 From: Basile STARYNKEVITCH 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