PR-673

Roland McGrath roland@frob.com
Mon Aug 24 20:15:00 GMT 1998


> I just checked Tuomas Heino's mail with fork_debug-0.3.  

Whazzat?

> He uses fflush (NULL) before calling fork and exit which shows the
> problem.

Then we have a bug (though there may have been changes from Uli and HJ in
the last few days that fixed it).

> Using _exit instead of exit fixes the problem.

That should be obvious, and if it didn't then it would not really be a
stdio problem.  That is, _exit just does a syscall to kill the process,
nothing else whatsoever (it damn well better not).

> But shouldn't it work with fflush also (according to your description)?

Yes.  POSIX requires that fflush'ing a stream before fork (and with no
intervening operations on the stream, obviously) make that stream and its
associated file descriptor be synched up so that the parent and child see
the same (correct) behavior.  By extension, fflush(NULL) must make all
streams safe.  (There are various other things that also must make a stream
safe, the conditions are complex.)



More information about the Libc-hacker mailing list