Why does SIGPIPE exist?

后端 未结 5 986
梦如初夏
梦如初夏 2020-11-30 20:04

From my understanding, SIGPIPE can only occur as the result of a write(), which can (and does) return -1 and set errno to EPIPE<

5条回答
  •  再見小時候
    2020-11-30 21:00

    I think it is to get the error handling correct without requiring a lot of code in everything writing to a pipe.

    Some programs ignore the return value of write(); without SIGPIPE they would uselessly generate all output.

    Programs that check the return value of write() likely print an error message if it fails; this is inappropriate for a broken pipe as it is not really an error for the whole pipeline.

提交回复
热议问题