This is the mail archive of the libc-hacker@sourceware.cygnus.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: PR-673


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]