fork on uClinux

Rich Felker dalias at aerifal.cx
Sat May 27 06:59:06 UTC 2006


On Fri, May 26, 2006 at 11:32:44PM -0700, Carlos Manuel Duclos Vergara wrote:
> > No, you misunderstand. I did not say it would corrupt the FILE
> > structure. I said it would corrupt the actual _file_ on disk. That is,
> > each copy of the process will have a copy of the output buffer, and
> > they both will flush it, so the data will be written twice.
> >
> 
> this is not a bug nor a problem, it's just the way Unix systems treat the 
> files. Many processes can write to a file, and they all have their "private" 
> copy. However, only the last process to close the file actually make the 
> changes (the other processes also make changes, however since the last one 
> submits its own copy is almost the same thing)

No, it's not ok! The two copies will be written sequentially one after
the other, not over top of each other! This is obvious for non-
seekable file descriptors.

If you don't believe me on this, look it up! But it's well-known that
it's dangerous to flush streams in both the parent and child process
after a fork!

Rich




More information about the uClibc mailing list