caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Johann Spies <jspies@sun.ac.za>
To: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Unix.create_process vs Unix.open_process_out
Date: Mon, 14 Apr 2008 15:20:45 +0200	[thread overview]
Message-ID: <20080414132045.GA26399@sun.ac.za> (raw)
In-Reply-To: <20080414125557.11200@gmx.com>

On Mon, Apr 14, 2008 at 08:43:14AM -0400, James Jones wrote:
> 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?

Did you try "cat <file>" ?

If you just type 'cat' on the commandline it waits for input on
stdin.  If you 'cat <file>' it finishes the job and exit.

Regards
Johann
--
Johann Spies          Telefoon: 021-808 4036
Informasietegnologie, Universiteit van Stellenbosch

     "For the word of God is quick, and powerful, and  
      sharper than any twoedged sword, piercing even to  
      the dividing asunder of soul and spirit, and of the
      joints and marrow, and is a discerner of the thoughts
      and intents of the heart."      Hebrews 4:12 


  reply	other threads:[~2008-04-14 13:20 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-14 12:43 James Jones
2008-04-14 13:20 ` Johann Spies [this message]
2008-04-14 13:32 ` [Caml-list] " Gerd Stolpmann
2008-04-14 13:36 ` Gerd Stolpmann

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=20080414132045.GA26399@sun.ac.za \
    --to=jspies@sun.ac.za \
    --cc=caml-list@yquem.inria.fr \
    /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;
as well as URLs for NNTP newsgroup(s).