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.1 required=5.0 tests=AWL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id 72729BBCA for ; Mon, 14 Apr 2008 15:35:17 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AvwAAJ76AkjU4368k2dsb2JhbACBXo92AQEBAQkDCQkWmAgB X-IronPort-AV: E=Sophos;i="4.25,655,1199660400"; d="scan'208";a="24975188" Received: from moutng.kundenserver.de ([212.227.126.188]) by mail4-smtp-sop.national.inria.fr with ESMTP; 14 Apr 2008 15:35:17 +0200 Received: from gate.lan.gerd-stolpmann.de (dslb-084-059-097-242.pools.arcor-ip.net [84.59.97.242]) by mrelayeu.kundenserver.de (node=mrelayeu3) with ESMTP (Nemesis) id 0MKxQS-1JlOq33nIH-0003V8; Mon, 14 Apr 2008 15:35:16 +0200 Received: from [192.168.0.32] (fw.lan.gerd-stolpmann.de [192.168.1.1]) by gate.lan.gerd-stolpmann.de (Postfix) with ESMTP id A2E87C141; Mon, 14 Apr 2008 15:35:15 +0200 (CEST) Subject: Re: [Caml-list] Unix.create_process vs Unix.open_process_out From: Gerd Stolpmann To: James Jones Cc: caml-list@yquem.inria.fr In-Reply-To: <20080414125557.11200@gmx.com> References: <20080414125557.11200@gmx.com> Content-Type: text/plain Date: Mon, 14 Apr 2008 15:36:18 +0200 Message-Id: <1208180178.18538.10.camel@flake.lan.gerd-stolpmann.de> Mime-Version: 1.0 X-Mailer: Evolution 2.12.1 Content-Transfer-Encoding: 7bit X-Provags-ID: V01U2FsdGVkX19CDdvawF031QpzqBd6yu27qHOw4g1TtD/VppT LnF5p/vI0q7NypM35PcN8UeUAWmbSrl89iBLPJdUODl6Qjprpq JlFID0JoB3gnreGjrbyKJi14oe2QLMl X-Spam: no; 0.00; gerd:01 stolpmann:01 stdout:01 stderr:01 waitpid:01 stdout:01 stderr:01 waitpid:01 gerd:01 stdin:01 beginner's:01 ocaml:01 bug:01 stolpmann:01 viktoriastr:01 Am Montag, den 14.04.2008, 08:43 -0400 schrieb James Jones: > 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) P.S. You can close the "other" w by setting the close on exec flag: let test2 () = let r,w = Unix.pipe() in Unix.set_close_on_exec w; let pid = Unix.create_process "cat" [| "cat" |] r Unix.stdout Unix.stderr in Unix.close w; assert (snd (Unix.waitpid [] pid) = Unix.WEXITED 0);; Gerd > > > 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? > _______________________________________________ > Caml-list mailing list. Subscription management: > http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list > Archives: http://caml.inria.fr > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs -- ------------------------------------------------------------ Gerd Stolpmann * Viktoriastr. 45 * 64293 Darmstadt * Germany gerd@gerd-stolpmann.de http://www.gerd-stolpmann.de Phone: +49-6151-153855 Fax: +49-6151-997714 ------------------------------------------------------------