static size_t n_hooks;
static int signal_fds[2];
-HANDLE wevent;
+static HANDLE wevent;
static volatile sig_atomic_t stored_sig_nr = SIG_ATOMIC_MAX;
static struct ovs_mutex mutex;
static void atexit_handler(void);
static void call_hooks(int sig_nr);
+#ifdef _WIN32
+static BOOL WINAPI ConsoleHandlerRoutine(DWORD dwCtrlType);
+#endif
/* Initializes the fatal signal handling module. Calling this function is
* optional, because calling any other function in the module will also
char *msg_buf = ovs_lasterror_to_string();
VLOG_FATAL("Failed to create a event (%s).", msg_buf);
}
+
+ /* Register a function to handle Ctrl+C. */
+ SetConsoleCtrlHandler(ConsoleHandlerRoutine, true);
#endif
for (i = 0; i < ARRAY_SIZE(fatal_signals); i++) {
poll_fd_wait_event(signal_fds[0], wevent, POLLIN);
}
+void
+fatal_ignore_sigpipe(void)
+{
+#ifndef _WIN32
+ signal(SIGPIPE, SIG_IGN);
+#endif
+}
+
static void
atexit_handler(void)
{
}
}
}
+
+#ifdef _WIN32
+BOOL WINAPI ConsoleHandlerRoutine(DWORD dwCtrlType)
+{
+ stored_sig_nr = SIGINT;
+ SetEvent(wevent);
+ return true;
+}
+#endif
\f
/* Files to delete on exit. */
static struct sset files = SSET_INITIALIZER(&files);