PR-673

Andreas Schwab schwab@issan.informatik.uni-dortmund.de
Wed Aug 26 01:33:00 GMT 1998


Roland McGrath <roland@frob.com> writes:

|> 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.)

But the problem here is that the parent goes on reading from the stream
maybe before the child does exit(), in which case it's the child's stream
offset that becomes unaligned to the file offset, and then _IO_sync in the
child will clobber the file offset again.  Does POSIX allow that?
Normally you would either wait() for the child, or the child will just
call execv(), in both cases all stdio streams will stay quiet.

Andreas.



More information about the Libc-hacker mailing list