From 109d40f1e598f9d122a91ad0267e6ce199b174a4 Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Fri, 23 Jan 2015 12:00:54 +0100 Subject: Replace signal() by sigaction() --- src/DabMod.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/DabMod.cpp b/src/DabMod.cpp index cc7dd96..06d1254 100644 --- a/src/DabMod.cpp +++ b/src/DabMod.cpp @@ -71,13 +71,13 @@ typedef std::complex complexf; -bool running = true; +volatile sig_atomic_t running = 1; void signalHandler(int signalNb) { PDEBUG("signalHandler(%i)\n", signalNb); - running = false; + running = 0; } @@ -218,7 +218,14 @@ int main(int argc, char* argv[]) #endif InputReader* inputReader; - signal(SIGINT, signalHandler); + struct sigaction sa; + memset(&sa, 0, sizeof(struct sigaction)); + sa.sa_handler = &signalHandler; + + if (sigaction(SIGINT, &sa, NULL) == -1) { + perror("sigaction"); + return EXIT_FAILURE; + } // Set timezone to UTC setenv("TZ", "", 1); @@ -844,7 +851,7 @@ int main(int argc, char* argv[]) else { fprintf(stderr, "Input read error.\n"); } - running = false; + running = 0; } } catch (std::exception& e) { fprintf(stderr, "EXCEPTION: %s\n", e.what()); -- cgit v1.2.3