开发者

Is it recommended to trap SIGPIPE in bash script?

I have a problem while executing a bash script from C++ using the system call command. The script catches a SIGPIPE signal and exit with return code 141.

This problem has started to appear only in the last release of my code.

My Questions are as follows:

  1. Why does this SIGPIPE occur now and didn't occur before?
  2. Is it safe to ignore th开发者_Python百科e SIGPIPE and what are the consequences?


1) That's very hard to answer without knowing exactly what you changed.
2) If a sequence of commands appears in a pipeline, and one of the reading commands finishes before the writer has finished, the writer receives a SIGPIPE signal. So whether you can ignore it depends on whether that is acceptable behavior for your script. More info here


A current version of the FAQ that PiedPiper linked to states:

As of bash-3.1, bash does not report SIGPIPE errors by default. You can build a version of bash that will report such errors.

Is it possible that you changed Bash versions or the way it's built and that caused the change in behavior in your code?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜