From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id NAA13581; Sun, 8 Sep 2002 13:29:28 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id NAA13901 for ; Sun, 8 Sep 2002 13:29:27 +0200 (MET DST) Received: from mel-rto6.wanadoo.fr (smtp-out-6.wanadoo.fr [193.252.19.25]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id g88BTR901734 for ; Sun, 8 Sep 2002 13:29:27 +0200 (MET DST) Received: from mel-rta10.wanadoo.fr (193.252.19.193) by mel-rto6.wanadoo.fr (6.5.007) id 3D760C2500234068 for caml-list@inria.fr; Sun, 8 Sep 2002 13:29:27 +0200 Received: from debian (80.8.82.52) by mel-rta10.wanadoo.fr (6.5.007) id 3D775BB70016671D for caml-list@inria.fr; Sun, 8 Sep 2002 13:29:27 +0200 Received: from moi by debian with local (Exim 3.36 #1 (Debian)) id 17o0GS-0000ua-00 for ; Sun, 08 Sep 2002 13:30:04 +0200 To: caml-list@inria.fr Subject: Re: [Caml-list] Unix.wait: strange behavior References: <3D7B267E.8040101@fltrp.com> Mail-Copy-To: never From: Remi VANICAT Date: Sun, 08 Sep 2002 13:30:04 +0200 In-Reply-To: <3D7B267E.8040101@fltrp.com> (Yang Shouxun's message of "Sun, 08 Sep 2002 18:29:18 +0800") Message-ID: <871y84yb0j.dlv@wanadoo.fr> User-Agent: Gnus/5.090006 (Oort Gnus v0.06) Emacs/21.2 (i386-debian-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: 8bit Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Yang Shouxun 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