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=HTML_MESSAGE autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by yquem.inria.fr (Postfix) with ESMTP id D7497BBCA for ; Mon, 14 Apr 2008 14:56:00 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Aj8EAHrxAkhK0AVDZGdsb2JhbACCQzMpiA+GGRoCDAWYBA X-IronPort-AV: E=Sophos;i="4.25,655,1199660400"; d="scan'208,217";a="9554675" Received: from mail.gmx.com ([74.208.5.67]) by mail2-smtp-roc.national.inria.fr with SMTP; 14 Apr 2008 14:56:00 +0200 Received: (qmail 13108 invoked by uid 0); 14 Apr 2008 12:55:57 -0000 Received: from 67.177.185.135 by www-us014.gmx.net with HTTP; Mon, 14 Apr 2008 08:55:57 -0400 (EDT) Content-Type: multipart/alternative; boundary="========GMXBoundary11201208177757800755" Date: Mon, 14 Apr 2008 08:43:14 -0400 From: "James Jones" Message-ID: <20080414125557.11200@gmx.com> MIME-Version: 1.0 subject: Unix.create_process vs Unix.open_process_out To: caml-list@yquem.inria.fr X-Authenticated: #46952340 X-Flags: 0001 X-Mailer: WWW-Mail 6107 (Global Mail Exchange) X-Priority: 3 X-Provags-ID: V01U2FsdGVkX1+8TNsgoBm8tDKSLLO/fOk9h/TSYDTCt9DFAnMTvK Ce7VwvsY2amvTwYE7drDe2isWh8A1GV1jIGQ== X-Registered: 0 X-GMX-UID: FRJlIghyzmCiIe496icly6hiamdhZMR7 X-Spam: no; 0.00; stdout:01 stderr:01 waitpid:01 stdin:01 stdout:01 stderr:01 waitpid:01 stdin:01 height:98 border-left:98 ccc:98 padding-left:98 unix:01 unix:01 font-size:98 X-Attachments: cset="utf-8" --========GMXBoundary11201208177757800755 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit 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? --========GMXBoundary11201208177757800755 Content-Type: text/html; charset="utf-8" Content-Transfer-Encoding: quoted-printable Consider the following two functions:

let test1 () =3D
  let= w =3D Unix.open_process_out "cat" in
  assert (Unix.close_process_= out w =3D Unix.WEXITED 0)

let test2 () =3D
  let r,w =3D Uni= x.pipe () in
  let pid =3D Unix.create_process "cat" [| "cat" |] r = Unix.stdout Unix.stderr in
  Unix.close w;
  assert (snd (U= nix.waitpid [] pid) =3D Unix.WEXITED 0)


Both execute "cat" and t= hen close its stdin immediately. This should cause cat to terminate. In tes= t1 this works as expected but in test2, cat keeps running forever. Is this = the expected behavior of Unix.create_process? --========GMXBoundary11201208177757800755--