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 FAA25422; Sat, 14 Sep 2002 05:20:44 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id FAA25306 for ; Sat, 14 Sep 2002 05:20:43 +0200 (MET DST) X-SPAM-Warning: Sending machine is listed in blackholes.five-ten-sg.com Received: from mail.fltrp.com ([211.101.185.130]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id g8E3Kf129884 for ; Sat, 14 Sep 2002 05:20:42 +0200 (MET DST) Received: from fltrp.com [129.0.5.6] by mail.fltrp.com with ESMTP (SMTPD32-7.12 EVAL) id AAAD23100FE; Sat, 14 Sep 2002 11:19:09 +0800 Message-ID: <3D82AAB5.4060208@fltrp.com> Date: Sat, 14 Sep 2002 11:19:17 +0800 From: Yang Shouxun User-Agent: Mozilla/5.0 (X11; U; Linux i686; zh-CN; rv:1.0.0) Gecko/20020615 Debian/1.0.0-3 X-Accept-Language: en-us, zh-cn MIME-Version: 1.0 To: caml-list@inria.fr Subject: Re: [Caml-list] Unix.wait: strange behavior References: <3D7B267E.8040101@fltrp.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk As a follow-up to my initial post, I found that the strange behavior is due to the difference of toplevel and byte-compiled. The code, when byte-compiled, will act as described in the book. When run at the interactive toplevel, acts as I reported. That's a good lesson for me that there are big differences between the three different modes. Yang Shouxun wrote: > 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