From 2f694507513e44e59139f57f28e08c5d0772880e Mon Sep 17 00:00:00 2001 From: Bruce Cran Date: Wed, 10 Oct 2012 16:34:13 +0100 Subject: [PATCH] Windows: handle SIGBREAK. 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 --- backend.c | 8 ++++++++ client.c | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/backend.c b/backend.c index b5501c63..4e3a3ed5 100644 --- 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; diff --git a/client.c b/client.c index 93c7103f..bf09d7ef 100644 --- 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; -- 2.25.1