Windows: handle SIGBREAK.
authorBruce Cran <bruce@cran.org.uk>
Wed, 10 Oct 2012 15:34:13 +0000 (16:34 +0100)
committerJens Axboe <axboe@kernel.dk>
Wed, 10 Oct 2012 15:47:00 +0000 (09:47 -0600)
The only way to send a POSIX-style signal from another application on Windows
is to use GenerateConsoleCtrlEvent with either CTRL_C_EVENT or
CTRL_BREAK_EVENT. CTRL_BREAK_EVENT is the only one which gets through to
applications, so add a signal handler for it to allow fio to quit cleanly.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
backend.c
client.c

index b5501c63f76df6813f72a3c7bc6a93e90e505aea..4e3a3ed5701f8227cabddf3bf3af0a6b0750ee9a 100644 (file)
--- a/backend.c
+++ b/backend.c
@@ -108,6 +108,14 @@ static void set_sig_handlers(void)
        act.sa_flags = SA_RESTART;
        sigaction(SIGTERM, &act, NULL);
 
+/* Windows uses SIGBREAK as a quit signal from other applications */
+#ifdef WIN32
+       memset(&act, 0, sizeof(act));
+       act.sa_handler = sig_int;
+       act.sa_flags = SA_RESTART;
+       sigaction(SIGBREAK, &act, NULL);
+#endif
+
        memset(&act, 0, sizeof(act));
        act.sa_handler = sig_show_status;
        act.sa_flags = SA_RESTART;
index 93c7103f1a3f40f7a42fe2afa5ecea4c162147fc..bf09d7ef4dadad7a343ecda88a80aaca4e2053fe 100644 (file)
--- a/client.c
+++ b/client.c
@@ -383,6 +383,14 @@ static void client_signal_handler(void)
        act.sa_flags = SA_RESTART;
        sigaction(SIGTERM, &act, NULL);
 
+/* Windows uses SIGBREAK as a quit signal from other applications */
+#ifdef WIN32
+       memset(&act, 0, sizeof(act));
+       act.sa_handler = sig_int;
+       act.sa_flags = SA_RESTART;
+       sigaction(SIGBREAK, &act, NULL);
+#endif
+
        memset(&act, 0, sizeof(act));
        act.sa_handler = sig_show_status;
        act.sa_flags = SA_RESTART;