Red Hat Bugzilla – Bug 57159
a error has been occured using fork() function while the relust is output though pipe.
Last modified: 2007-04-18 12:38:35 EDT
Description of Problem:
using fork() function to create chile process;the result of #./foo is
different from #./foo >foo1.c
Version-Release number of selected component (if applicable):
It is so easy a C programe,compile and run the source code .that's all.
Steps to Reproduce:
1. #gcc -g -o foo foo.c
3. #./foo >foo1.c
Two results is so much different.
Two results are no difference.
the source code ,the two relusts with email .
Created attachment 39828 [details]
source code and result of test
Note more appropriate forum for this would be some unix basics news forum,
not a bug report.
Essentially what happens is that you use a buffered stdio without flushing,
so you really cannot wonder that if its output was only buffered not printed
before fork, that the buffered output will be flushed both in the parent
and in the child. E.g. fflush(stdout); before the fork() calls could do the