As
Corion said, you create processes with fork(), not threads. If you have multiple writers to a file then there are several solutions - none of them particularly good!
The simplest is to lock the whole file for each writer - but that defeats the object of having multiple writers.
Another is to allocate specific regions (by byte offset) of the file for each thread/process ensuring that these do not overlap. That avoids locking, but requires some planning and management. Use
seek to position each thread/process.
If you turn off buffering for the write you will reduce the overlap, but probably not get rid of it altogether.