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 PAA08480; Mon, 17 Nov 2003 15:19:29 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id PAA08582 for ; Mon, 17 Nov 2003 15:19:27 +0100 (MET) Received: from inria.fr (macaque.inria.fr [128.93.8.158]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id hAHEJR108951 for ; Mon, 17 Nov 2003 15:19:27 +0100 (MET) Date: Mon, 17 Nov 2003 15:19:59 +0100 Subject: Re: [Caml-list] GC and file descriptors Content-Type: text/plain; charset=US-ASCII; format=flowed Mime-Version: 1.0 (Apple Message framework v552) From: Damien Doligez To: Caml Mailing List Content-Transfer-Encoding: 7bit In-Reply-To: <3FB4ED56.6020804@univ-savoie.fr> Message-Id: <20332275-1909-11D8-8941-00039310CAE8@inria.fr> X-Mailer: Apple Mail (2.552) X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 damien:01 damien:01 raffalli:01 descriptor:01 sigpipe:01 side-effect:01 side-effect:01 sloppy:01 christophe:01 semantics:01 inherit:01 descriptors:01 descriptors:01 doligez:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Friday, November 14, 2003, at 03:57 PM, Christophe Raffalli wrote: > Why ? Could you elaborate ? This is what I had in mind: If your file descriptor f is bound to a pipe, then close() will send a SIGPIPE or and end-of-file to the process at the other end of the pipe. This is a visible side-effect. If f is bound to a socket, then close() will not only send and end-of-file to the other end, but it will also release the port number, changing the outcome of a further bind() call. Another side-effect. If you call exec(), then the new program will inherit all open file descriptors. More visible side-effects. More examples (that I hadn't thought of) were given by other people on this list. For these reasons, close() must be provided to the programmer for explicit calling, because its semantics goes beyond simple deallocation of resource. Since close() is provided, if you want the GC to close your descriptors, you can attach finalisation functions to them. In that case, don't forget to call Gc.full_major() before exec(). In my opinion, doing it automatically would only encourage sloppy programming by hiding errors in a non-deterministic way. -- Damien ------------------- 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