From: Nicolas FRANCOIS (AKA El Bofo) <nicolas.francois@free.fr>
To: David Fox <david@lindows.com>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] process conundrum
Date: Thu, 14 Feb 2002 14:42:27 +0100 [thread overview]
Message-ID: <20020214144227.3a700da4.nicolas.francois@free.fr> (raw)
In-Reply-To: <87adudcb2l.fsf@foxthompson.net>
On 13 Feb 2002 13:43:14 -0800
David Fox <david@lindows.com> wrote:
> Suppose I open a process to reverse the lines of a file like so:
>
> # let readable, writable =
> Unix.open_process "cat -n | sort -n -r | sed 's:^[ 0-9]*[^ 0-9]::'";;
>
> Then I write a few lines to it:
>
> # output_string writable "a\n";;
> # output_string writable "b\n";;
> # output_string writable "c\n";;
>
> Now I close the write end to cause an EOF, so the output arrives on
> readable:
>
> # close_out writable;;
> # input_line readable;;
> - : string = "c"
> # input_line readable;;
> - : string = "b"
> # input_line readable;;
> - : string = "a"
> # input_line readable;;
> Exception: End_of_file.
This can be avoided with a
try ... with End_of_file -> ...
> How do I cleanly terminate the process?
>
> # Unix.close_process (readable, writable);;
> Exception: Sys_error "Bad file descriptor".
I tried your example and only got a
# Unix.close_process (readable, writable);;
- : Unix.process_status = WEXITED 0
So what's the problem ?
\bye
--
Nicolas FRANCOIS
http://nicolas.francois.free.fr
A TRUE Klingon programmer does NOT comment his code
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
next prev parent reply other threads:[~2002-02-14 14:06 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-02-13 21:43 David Fox
2002-02-14 13:42 ` Nicolas FRANCOIS [this message]
2002-02-15 16:07 ` Xavier Leroy
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=20020214144227.3a700da4.nicolas.francois@free.fr \
--to=nicolas.francois@free.fr \
--cc=caml-list@inria.fr \
--cc=david@lindows.com \
/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