From: Gerd Stolpmann <info@gerd-stolpmann.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 22:28:53 +0100 [thread overview]
Message-ID: <1395696533.27397.36.camel@zotac> (raw)
In-Reply-To: <53307809.80202@ens-cachan.org>
[-- Attachment #1: Type: text/plain, Size: 1054 bytes --]
Am Montag, den 24.03.2014, 19:23 +0100 schrieb Johan Grande:
> Hi,
>
> In the following program, the child process "cat" never terminates. I
> don't understand why; can anyone tell me?
Because outdescr isn't closed in the child. Set the close-on-exec flag
on it.
Gerd
> ~~~
> 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 *)
> ~~~
>
> --
> Johan Grande
>
--
------------------------------------------------------------
Gerd Stolpmann, Darmstadt, Germany gerd@gerd-stolpmann.de
My OCaml site: http://www.camlcity.org
Contact details: http://www.camlcity.org/contact.html
Company homepage: http://www.gerd-stolpmann.de
------------------------------------------------------------
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 490 bytes --]
next prev parent reply other threads:[~2014-03-24 21:28 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 [this message]
2014-03-24 23:59 ` Johan Grande
2014-03-24 22:55 ` oliver
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=1395696533.27397.36.camel@zotac \
--to=info@gerd-stolpmann.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