From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Delivered-To: caml-list@yquem.inria.fr Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id 2ABF5BC48 for ; Mon, 7 Mar 2005 15:10:33 +0100 (CET) Received: from kraid.nerim.net (smtp-101-monday.nerim.net [62.4.16.101]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id j27EATRE008190 for ; Mon, 7 Mar 2005 15:10:30 +0100 Received: from localhost (karryall.dnsalias.org [62.4.18.180]) by kraid.nerim.net (Postfix) with ESMTP id 98DF041C97; Mon, 7 Mar 2005 15:10:28 +0100 (CET) Date: Mon, 07 Mar 2005 15:10:29 +0100 (CET) Message-Id: <20050307.151029.41642248.oandrieu@nerim.net> To: micha-1@fantasymail.de Cc: caml-list@yquem.inria.fr Subject: Re: [Caml-list] printf and fork question From: Olivier Andrieu In-Reply-To: <20050307144422.1e67bef6.micha-1@fantasymail.de> References: <20050307144422.1e67bef6.micha-1@fantasymail.de> X-Mailer: Mew version 4.1 on Emacs 21.3 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Miltered: at nez-perce with ID 422C60D5.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 printf:01 andrieu:01 andrieu:01 ijm:01 printf:01 getpid:01 waitpid:01 ocaml:01 stdout:01 buffer:01 stays:98 unix:01 inherit:01 jussieu:01 X-Spam-Checker-Version: SpamAssassin 3.0.2 (2004-11-16) on yquem.inria.fr X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.2 X-Spam-Level: > Michael [Mon, 7 Mar 2005]: > Hi, > > I don't understand why this: > > open Unix;; > let _ = > Printf.printf "Hi! %d\n" (getpid()); > match fork() with > | 0 -> if fork() <> 0 then exit 0; > () > | id -> ignore (waitpid [] id) > > prints out that: > Hi! 12215 > Hi! 12215 > Hi! 12215 > > > with ocaml 3.08.2. Any hints? You haven't flushed stdout : so the Hi! stays in the buffer and the children inherit it. -- Olivier