Why does this C program generate SIGPIPE later than expected?

This program generates `SIGPIPE` after piping it to "`head -n 1`", after a random time. I understand that because we're feeding more to "`head -n 1`" after the first line, we would expect it to generate `SIGPIPE`, but instead it will make it to a random number (usually > 20 and < 200) before exitting. Any idea why? #include #include main() { int i; char *s = "ABCDEFGHIJKLMNOPQRSTUVWXYZ\n"; i = 0; while (1) { fputs(s, stdout); fflush(stdout); fprintf(stderr, "Iteration %d done\n", i); i++; } } This is not homework, just something in my professor's notes that I do not understand.
Ehm, const char *s = ...

以上就是Why does this C program generate SIGPIPE later than expected?的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » CSS3 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准

联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏