PR-673

Andreas Schwab schwab@issan.informatik.uni-dortmund.de
Mon Aug 24 01:47:00 GMT 1998


I have taken a look at PR-673 and i think this is not a bug in libio.  The
problem is that a file descriptor is shared via a stdio stream between two
processes when the child is calling exit().  Then, in _IO_unbuffer_all,
the stream is made unbuffered, causing the file descriptor to be synced to
the stream position.  Since the file offset is shared this also affects
the parent, which however does not know about that, and its stream offset
becomes unaligned with the underlying file offset.  If you strace the
_llseek calls you will notice that many of them will fail with EINVAL
because the effective file position is made negative.

Now the whole problem disappears if the child does not call exit(), but
_exit().  I don't know what POSIX says, but i think that calling exit() in
a child process should be considered invoking undefined behaviour.

Andreas.



More information about the Libc-hacker mailing list