diff options
author | Matthias P. Braendli <matthias.braendli@mpb.li> | 2015-01-23 12:00:54 +0100 |
---|---|---|
committer | Matthias P. Braendli <matthias.braendli@mpb.li> | 2015-01-23 12:00:54 +0100 |
commit | 109d40f1e598f9d122a91ad0267e6ce199b174a4 (patch) | |
tree | fe355fb8ea320ac25f2984bcd18882f55c54a005 /src | |
parent | 2e646a26c9db66dd5776667d9c9b73d798f5ffda (diff) | |
download | dabmod-109d40f1e598f9d122a91ad0267e6ce199b174a4.tar.gz dabmod-109d40f1e598f9d122a91ad0267e6ce199b174a4.tar.bz2 dabmod-109d40f1e598f9d122a91ad0267e6ce199b174a4.zip |
Replace signal() by sigaction()
Diffstat (limited to 'src')
-rw-r--r-- | src/DabMod.cpp | 15 |
1 files changed, 11 insertions, 4 deletions
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<float> 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()); |