Re: Kernel 2.2.x bug. Standard output not flushed before fork

Miquel van Smoorenburg (miquels@cistron.nl)
7 Jun 1999 23:07:29 +0200


In article <cistron.375C1AC0.30512697@ditec.um.es>,
Juan Piernas =?iso-8859-1?Q?C=E1novas?= <piernas@ditec.um.es> wrote:
>Hi all!
>This is not good, isn't it?. Well, I have a program that
>creates one o more process. Before fork, the father
>process write some messages to standard output and then it
>creates some sons. The problem is sons inherit
>father's non flushed standard output, so father's messages
>appear two o more times. If I flush standard output before
>fork(), all is fine -- that is, father's messages appear
>once.

Yes. That's standard Unix behaviour, and the kernel doesn't have anything
to do with it. The stdio buffers live in libc only - the kernel doesn't
know about them. It's the programmers responsibility to make sure all stdio
buffers are flushed before forking.

Mike.

-- 
Indifference will certainly be the downfall of mankind, but who cares?

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/