关于 fork

来源:互联网 发布:路由器突然没有网络了 编辑:程序博客网 时间:2024/04/29 11:45

 如果在fork调用前,调用如下语句:

fprintf (stdout, "xxxx/n");

那么在stdout没有被redirect的情况下,stdout只会输出一份"xxxx/n", 但是如果stdout被redirect到文件的话,stdout就会print 两份 "xxxx/n"

因为stdout是在printf的函数中是line buffer,而文件在printf函数中是full buffer

原创粉丝点击