From: Bruce Cran Date: Wed, 10 Oct 2012 15:34:13 +0000 (+0100) Subject: Windows: handle SIGBREAK. X-Git-Tag: fio-2.0.10~1 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=2f694507513e44e59139f57f28e08c5d0772880e 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 --- 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;