From: oliver <oliver@first.in-berlin.de>
To: Johan Grande <johan.grande@ens-cachan.org>
Cc: caml users <caml-list@inria.fr>
Subject: Re: [Caml-list] Child process doesn't terminate
Date: Mon, 24 Mar 2014 23:55:58 +0100 [thread overview]
Message-ID: <20140324225558.GA13355@siouxsie> (raw)
In-Reply-To: <53307809.80202@ens-cachan.org>
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
next prev parent reply other threads:[~2014-03-24 22:56 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-24 18:23 Johan Grande
2014-03-24 21:28 ` Gerd Stolpmann
2014-03-24 23:59 ` Johan Grande
2014-03-24 22:55 ` oliver [this message]
2014-03-25 0:10 ` Johan Grande
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20140324225558.GA13355@siouxsie \
--to=oliver@first.in-berlin.de \
--cc=caml-list@inria.fr \
--cc=johan.grande@ens-cachan.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox