[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Yang Shouxun <yangsx@f...> |
| Subject: | [Caml-list] Unix.wait: strange behavior |
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?
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.
-------------------
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