From: Remi VANICAT <vanicat@labri.u-bordeaux.fr>
To: caml-list@inria.fr
Subject: Re: [Caml-list] Unix.wait: strange behavior
Date: Sun, 08 Sep 2002 13:30:04 +0200 [thread overview]
Message-ID: <871y84yb0j.dlv@wanadoo.fr> (raw)
In-Reply-To: <3D7B267E.8040101@fltrp.com> (Yang Shouxun's message of "Sun, 08 Sep 2002 18:29:18 +0800")
Yang Shouxun <yangsx@fltrp.com> writes:
> Hi,
>
> I'm reading ocaml-book English version. On p. 611:
> ----8<----
> match Unix.fork () with
> 0 -> Printf.printf "fair Marquise " ; flush stdout
> | _ -> ignore (Unix.wait ()) ;
> match Unix.fork () with
> 0 -> Printf.printf "your beautiful eyes " ; flush stdout
> | _ -> ignore (Unix.wait ()) ;
> match Unix.fork () with
> 0 -> Printf.printf "make me die " ; flush stdout
> | _ -> ignore (Unix.wait ()) ;
> Printf.printf "of love\n" ;
> flush stdout
> ----8<----
> this is intended to show the use of Unix.wait to wait for the
> termination of the child.
>
> Strangely, when I input at the Ocaml toplevel, it does not print "fair
> Marquise your beautiful eyes make me die of love", but only "fair
> Marquise". The forked processes did not terminate for some reason,
> which I don't understand why. Is this a bug?
Mmm, Don't know if this a bug or not, but the problem is that after
forking, you have two toplevel, so personally I've something like :
# match Unix.fork () with
0 -> Printf.printf "fair Marquise " ; flush stdout
[....]
fair Marquise - : unit = ()
# #quit
;;
your beautiful eyes - : unit = ()
# #quit ;;
make me die - : unit = ()
# #quit ;;
of love
- : unit = ()
#
>
> Guessing that the child processes will not automatically exit, I added
> "; exit 0" to the lines for newly forked processes, and I got "your
> beautiful eyes make me die of love" printed before the return of the
> expression and then "fair Marquise " printed.
Strange, I've the waited output.
--
Rémi Vanicat
vanicat@labri.u-bordeaux.fr
http://dept-info.labri.u-bordeaux.fr/~vanicat
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
next prev parent reply other threads:[~2002-09-08 11:29 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-09-08 10:29 Yang Shouxun
2002-09-08 11:30 ` Remi VANICAT [this message]
2002-09-14 3:19 ` Yang Shouxun
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=871y84yb0j.dlv@wanadoo.fr \
--to=vanicat@labri.u-bordeaux.fr \
--cc=caml-list@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