Browse thread
printf and fork question
-
Michael
- Gerd Stolpmann
- Basile STARYNKEVITCH
- David Fox
- Olivier Andrieu
- Michael
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Basile STARYNKEVITCH <basile@s...> |
| Subject: | Re: [Caml-list] printf and fork question |
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