caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Basile STARYNKEVITCH <basile@starynkevitch.net>
To: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] printf and fork question
Date: Mon, 7 Mar 2005 15:03:33 +0100	[thread overview]
Message-ID: <20050307140332.GA23926@ours.starynkevitch.net> (raw)
In-Reply-To: <20050307144422.1e67bef6.micha-1@fantasymail.de>

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: basile<at>starynkevitch<dot>net 
aliases: basile<at>tunes<dot>org = bstarynk<at>nerim<dot>net
8, rue de la Faïencerie, 92340 Bourg La Reine, France


  parent reply	other threads:[~2005-03-07 14:03 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-03-07 13:44 Michael
2005-03-07 13:57 ` [Caml-list] " Gerd Stolpmann
2005-03-07 14:03 ` Basile STARYNKEVITCH [this message]
2005-03-07 14:05 ` David Fox
2005-03-07 14:10 ` Olivier Andrieu
     [not found] ` <6b8a9142050307060758200ad3@mail.gmail.com>
2005-03-07 14:12   ` Michael

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20050307140332.GA23926@ours.starynkevitch.net \
    --to=basile@starynkevitch.net \
    --cc=caml-list@yquem.inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).