+ *
+ * Discard the SIGPIPE from write(), not
+ * disturbing any SIGPIPE that might be
+ * already pending. If a bogus SIGPIPE
+ * is sent to the entire process
+ * concurrently by a malicious user, it
+ * may be simply discarded.
+ */
+ ret = sigemptyset(&pending_set);
+ assert(!ret);
+ /*
+ * sigpending returns the mask
+ * of signals that are _both_
+ * blocked for the thread _and_
+ * pending for either the thread
+ * or the entire process.
+ */
+ ret = sigpending(&pending_set);
+ assert(!ret);
+ sigpipe_was_pending = sigismember(&pending_set, SIGPIPE);
+ /*
+ * If sigpipe was pending, it
+ * means it was already blocked,
+ * so no need to block it.