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 PAA19975; Thu, 14 Feb 2002 15:06:18 +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 PAA20812 for ; Thu, 14 Feb 2002 15:06:13 +0100 (MET) Received: from postfix3-2.free.fr (postfix3-2.free.fr [213.228.0.169]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id g1EE6Dj05446 for ; Thu, 14 Feb 2002 15:06:13 +0100 (MET) Received: from lfs (strasbourg-1-a7-9-109.dial.proxad.net [62.147.9.109]) by postfix3-2.free.fr (Postfix) with SMTP id B2FD718161; Thu, 14 Feb 2002 15:06:11 +0100 (CET) Date: Thu, 14 Feb 2002 14:42:27 +0100 From: Nicolas FRANCOIS (AKA El Bofo) To: David Fox Cc: caml-list@inria.fr Subject: Re: [Caml-list] process conundrum Message-Id: <20020214144227.3a700da4.nicolas.francois@free.fr> In-Reply-To: <87adudcb2l.fsf@foxthompson.net> References: <87adudcb2l.fsf@foxthompson.net> X-Mailer: Sylpheed version 0.7.1 (GTK+ 1.2.10; i686-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On 13 Feb 2002 13:43:14 -0800 David Fox wrote: > Suppose I open a process to reverse the lines of a file like so: > > # let readable, writable = > Unix.open_process "cat -n | sort -n -r | sed 's:^[ 0-9]*[^ 0-9]::'";; > > Then I write a few lines to it: > > # output_string writable "a\n";; > # output_string writable "b\n";; > # output_string writable "c\n";; > > Now I close the write end to cause an EOF, so the output arrives on > readable: > > # close_out writable;; > # input_line readable;; > - : string = "c" > # input_line readable;; > - : string = "b" > # input_line readable;; > - : string = "a" > # input_line readable;; > Exception: End_of_file. This can be avoided with a try ... with End_of_file -> ... > How do I cleanly terminate the process? > > # Unix.close_process (readable, writable);; > Exception: Sys_error "Bad file descriptor". I tried your example and only got a # Unix.close_process (readable, writable);; - : Unix.process_status = WEXITED 0 So what's the problem ? \bye -- Nicolas FRANCOIS http://nicolas.francois.free.fr A TRUE Klingon programmer does NOT comment his code ------------------- Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr