fork() and file descriptors with un-flushed output

Daniel Colascione
Tue Aug 28 07:09:00 GMT 2012

On 8/27/2012 11:26 PM, thoni56 wrote:
> Is this a known behaviour? Unavoidable in cygwin? (Obviously not, if I'm on
> the right track with my guesswork...) If it is a bug, will it be fixed?

This behavior isn't Cygwin-specific. In fact, it's longstanding Unix behavior.
(The buffering problem is one reason you should, generally speaking, use
_exit(2), not exit(3), in a forked child.) Calling fflush(NULL) before the fork
will flush all stdio buffers for you and eliminate the problem, assuming you're

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 259 bytes
Desc: OpenPGP digital signature
URL: <>

More information about the Cygwin mailing list