From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id AD13FBC84 for ; Mon, 7 Mar 2005 15:03:33 +0100 (CET) Received: from mallaury.noc.nerim.net (smtp-101-monday.noc.nerim.net [62.4.17.101]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id j27E3XQU020498 for ; Mon, 7 Mar 2005 15:03:33 +0100 Received: from hector.lesours (ours.starynkevitch.net [62.212.121.80]) by mallaury.noc.nerim.net (Postfix) with ESMTP id F14E462E4D for ; Mon, 7 Mar 2005 15:03:31 +0100 (CET) Received: from basile by hector.lesours with local (Exim 4.50) id 1D8IpZ-0006FM-1b for caml-list@yquem.inria.fr; Mon, 07 Mar 2005 15:03:33 +0100 Date: Mon, 7 Mar 2005 15:03:33 +0100 To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] printf and fork question Message-ID: <20050307140332.GA23926@ours.starynkevitch.net> References: <20050307144422.1e67bef6.micha-1@fantasymail.de> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20050307144422.1e67bef6.micha-1@fantasymail.de> User-Agent: Mutt/1.5.6+20040907i From: Basile STARYNKEVITCH X-Miltered: at concorde with ID 422C5F35.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 printf:01 basile:01 basile:01 ecrivait:01 printf:01 getpid:01 stdout:01 waitpid:01 forks:01 nerim:01 faiencerie:01 92340:01 reine:01 wrote:01 X-Spam-Checker-Version: SpamAssassin 3.0.2 (2004-11-16) on yquem.inria.fr X-Spam-Status: No, score=0.1 required=5.0 tests=FORGED_RCVD_HELO autolearn=disabled version=3.0.2 X-Spam-Level: Le Mon, Mar 07, 2005 at 02:44:22PM +0100, Michael écrivait/wrote: > Hi, > > I don't understand why this: > > open Unix;; > let _ = > Printf.printf "Hi! %d\n" (getpid()); I suggest adding a flush stdout; at this point. Flushing buffers is always good (and not language related) before forking under Unix. > match fork() with > | 0 -> if fork() <> 0 then exit 0; > () > | id -> ignore (waitpid [] id) > > prints out that: > Hi! 12215 > Hi! 12215 I don't know what is happening, but if the the flushing occurs after the forks - eg at program exit - the behavior is understandable. Regards. -- Basile STARYNKEVITCH http://starynkevitch.net/Basile/ email: basilestarynkevitchnet aliases: basiletunesorg = bstarynknerimnet 8, rue de la Faïencerie, 92340 Bourg La Reine, France