From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by yquem.inria.fr (Postfix) with ESMTP id 25143BBCA for ; Mon, 14 Apr 2008 15:20:55 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AtQAABv3AkiS6EANmmdsb2JhbACRVQEBAQEBCAUJBxaYBA X-IronPort-AV: E=Sophos;i="4.25,655,1199660400"; d="scan'208";a="11429228" Received: from unknown (HELO mail3.sun.ac.za) ([146.232.64.13]) by mail3-smtp-sop.national.inria.fr with ESMTP; 14 Apr 2008 15:20:53 +0200 Received: from werkesel.sun.ac.za ([146.232.129.30]) by mail3.sun.ac.za with esmtp (Exim 4.63) (envelope-from ) id 1JlOc2-0003LP-16 for caml-list@yquem.inria.fr; Mon, 14 Apr 2008 15:20:46 +0200 Received: from js by werkesel.sun.ac.za with local (Exim 4.69) (envelope-from ) id 1JlOc1-0006sv-Hm for caml-list@yquem.inria.fr; Mon, 14 Apr 2008 15:20:45 +0200 Date: Mon, 14 Apr 2008 15:20:45 +0200 From: Johann Spies To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Unix.create_process vs Unix.open_process_out Message-ID: <20080414132045.GA26399@sun.ac.za> Mail-Followup-To: Johann Spies , caml-list@yquem.inria.fr References: <20080414125557.11200@gmx.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20080414125557.11200@gmx.com> User-Agent: Mutt/1.5.17+20080114 (2008-01-14) X-Spam: no; 0.00; spies:01 jspies:01 stdout:01 stderr:01 waitpid:01 stdin:01 stdin:01 spies:01 universiteit:01 stellenbosch:01 021:98 asunder:98 wrote:01 unix:01 unix:01 On Mon, Apr 14, 2008 at 08:43:14AM -0400, James Jones wrote: > Consider the following two functions: > > let test1 () = > let w = Unix.open_process_out "cat" in > assert (Unix.close_process_out w = Unix.WEXITED 0) > > let test2 () = > let r,w = Unix.pipe () in > let pid = Unix.create_process "cat" [| "cat" |] r Unix.stdout Unix.stderr in > Unix.close w; > assert (snd (Unix.waitpid [] pid) = Unix.WEXITED 0) > > > Both execute "cat" and then close its stdin immediately. This should cause cat > to terminate. In test1 this works as expected but in test2, cat keeps running > forever. Is this the expected behavior of Unix.create_process? Did you try "cat " ? If you just type 'cat' on the commandline it waits for input on stdin. If you 'cat ' it finishes the job and exit. Regards Johann -- Johann Spies Telefoon: 021-808 4036 Informasietegnologie, Universiteit van Stellenbosch "For the word of God is quick, and powerful, and sharper than any twoedged sword, piercing even to the dividing asunder of soul and spirit, and of the joints and marrow, and is a discerner of the thoughts and intents of the heart." Hebrews 4:12