fork on uClinux

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


On Fri, May 26, 2006 at 05:28:45PM -0600, Shaun Jackman wrote:
> On 5/26/06, Rich Felker <dalias at aerifal.cx> wrote:
> >Normally you want to use _exit instead of exit regardless of whether
> >you fork or vfork. Otherwise stdout (and any other streams) will be
> >flushed in both parent and child and the data will be written twice,
> >resulting in file corruption.
> 
> This behaviour is true only of vfork and not of fork. Forked processes
> do not share a data segment, and so closing streams in one does not
> affect the other.

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.

Rich




More information about the uClibc mailing list