- // SIGKILL and SIGSTOP can't be handled
- if (sig != SIGKILL && sig != SIGSTOP) {
- if (sigaction(sig, NULL, &old_actions[sig]) >= 0) {
- sigaction(sig, &new_action, NULL);
- }
+ // SIGKILL and SIGSTOP can't be handled.
+ if (sig == SIGKILL || sig == SIGSTOP) {
+ continue;
+ }
+
+ /*
+ * SIGPIPE can be emitted when writing to stderr that is redirected
+ * to a pipe without readers. It is also very unlikely to ocurr
+ * inside graphics APIs, and most applications where it can occur
+ * normally already ignore it. In summary, it is unlikely that a
+ * SIGPIPE will cause abnormal termination, which it is likely that
+ * intercepting here will cause problems, so simple don't intercept
+ * it here.
+ */
+ if (sig == SIGPIPE) {
+ continue;
+ }
+
+ if (sigaction(sig, NULL, &old_actions[sig]) >= 0) {
+ sigaction(sig, &new_action, NULL);