+/* Check whether a fatal signal has occurred and, if so, call the fatal signal
+ * hooks and exit.
+ *
+ * This function is called automatically by poll_block(), but specialized
+ * programs that may not always call poll_block() on a regular basis should
+ * also call it periodically. (Therefore, any function with "block" in its
+ * name should call fatal_signal_run() each time it is called, either directly
+ * or through poll_block(), because such functions can only used by specialized
+ * programs that can afford to block outside their main loop around
+ * poll_block().)
+ */
+void
+fatal_signal_run(void)
+{
+ sig_atomic_t sig_nr;
+
+ fatal_signal_init();
+
+ sig_nr = stored_sig_nr;
+ if (sig_nr != SIG_ATOMIC_MAX) {
+ char namebuf[SIGNAL_NAME_BUFSIZE];
+
+ ovs_mutex_lock(&mutex);
+
+#ifndef _WIN32
+ VLOG_WARN("terminating with signal %d (%s)",
+ (int)sig_nr, signal_name(sig_nr, namebuf, sizeof namebuf));
+#else
+ VLOG_WARN("terminating with signal %d", (int)sig_nr);
+#endif
+ call_hooks(sig_nr);
+
+ /* Re-raise the signal with the default handling so that the program
+ * termination status reflects that we were killed by this signal */
+ signal(sig_nr, SIG_DFL);
+ raise(sig_nr);
+
+ ovs_mutex_unlock(&mutex);
+ OVS_NOT_REACHED();
+ }
+}
+
+void
+fatal_signal_wait(void)
+{
+ fatal_signal_init();
+ poll_fd_wait_event(signal_fds[0], wevent, POLLIN);
+}
+
+void
+fatal_ignore_sigpipe(void)
+{
+#ifndef _WIN32
+ signal(SIGPIPE, SIG_IGN);
+#endif