From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by sympa.inria.fr (Postfix) with ESMTPS id B43317F8A0 for ; Mon, 24 Mar 2014 23:56:02 +0100 (CET) Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of oliver@first.in-berlin.de) identity=pra; client-ip=192.109.42.8; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="oliver@first.in-berlin.de"; x-sender="oliver@first.in-berlin.de"; x-conformance=sidf_compatible Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of oliver@first.in-berlin.de) identity=mailfrom; client-ip=192.109.42.8; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="oliver@first.in-berlin.de"; x-sender="oliver@first.in-berlin.de"; x-conformance=sidf_compatible Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@einhorn.in-berlin.de) identity=helo; client-ip=192.109.42.8; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="oliver@first.in-berlin.de"; x-sender="postmaster@einhorn.in-berlin.de"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AlsCAB23MFPAbSoIf2dsb2JhbABZhx+6DYVdgSIWDgEBCwsKCBQogiUBAQEEI1YQCwkPAgIFIQICDwUYMYgMBKxiolAXFoETjVEHgm81gRQEj1mIcIZIjxg X-IPAS-Result: AlsCAB23MFPAbSoIf2dsb2JhbABZhx+6DYVdgSIWDgEBCwsKCBQogiUBAQEEI1YQCwkPAgIFIQICDwUYMYgMBKxiolAXFoETjVEHgm81gRQEj1mIcIZIjxg X-IronPort-AV: E=Sophos;i="4.97,723,1389740400"; d="scan'208";a="64531827" Received: from einhorn.in-berlin.de ([192.109.42.8]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-SHA; 24 Mar 2014 23:56:02 +0100 X-Envelope-From: oliver@first.in-berlin.de Received: from first (e178028155.adsl.alicedsl.de [85.178.28.155]) (authenticated bits=0) by einhorn.in-berlin.de (8.14.4/8.14.4/Debian-4) with ESMTP id s2OMtwt4032160 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Mon, 24 Mar 2014 23:56:00 +0100 Received: by first (Postfix, from userid 1000) id AA50F1548863; Mon, 24 Mar 2014 23:55:58 +0100 (CET) Date: Mon, 24 Mar 2014 23:55:58 +0100 From: oliver To: Johan Grande Cc: caml users Message-ID: <20140324225558.GA13355@siouxsie> References: <53307809.80202@ens-cachan.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <53307809.80202@ens-cachan.org> User-Agent: Mutt/1.5.20 (2009-06-14) Subject: Re: [Caml-list] Child process doesn't terminate Hello, On Mon, Mar 24, 2014 at 07:23:05PM +0100, Johan Grande wrote: > Hi, > > In the following program, the child process "cat" never terminates. > I don't understand why; can anyone tell me? > > ~~~ > let _ = > let open Unix in > let indescr, outdescr = pipe () in > let outchan = out_channel_of_descr outdescr in > let pid = > create_process "/bin/cat" [|"cat"|] > indescr stdout stderr > in > Printf.fprintf outchan "Hello!\n%!"; > close indescr; > close outdescr; > ignore (waitpid [] pid) (* stuck here *) > ~~~ "cat" does not terminate. With create_process "/bin/cat" [| "cat"; "/etc/passwd" |] cat would terminate after cat'ing the file, otherwise it reads from input until Ctrl-D arrives, before printing the data and then terminates. So you can wait in vain with your waitpid-call, if you call it as you did. Ciao, Oliver