From 8cec95b777f9e52efceb558f47804572b9752b88 Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Mon, 3 Oct 2016 20:33:20 +0200 Subject: Avoid deadlock on receiving signal --- src/DabMux.cpp | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/DabMux.cpp b/src/DabMux.cpp index 9699ea6..689b762 100644 --- a/src/DabMux.cpp +++ b/src/DabMux.cpp @@ -139,37 +139,40 @@ using boost::property_tree::ptree_error; volatile sig_atomic_t running = 1; +/* We are not allowed to use etiLog in the signal handler, + * because etiLog uses mutexes + */ void signalHandler(int signum) { #ifdef _WIN32 - etiLog.log(debug, "\npid: %i\n", _getpid()); + fprintf(stderr, "\npid: %i\n", _getpid()); #else - etiLog.log(debug, "\npid: %i, ppid: %i\n", getpid(), getppid()); + fprintf(stderr, "\npid: %i, ppid: %i\n", getpid(), getppid()); #endif #define SIG_MSG "Signal received: " switch (signum) { #ifndef _WIN32 case SIGHUP: - etiLog.log(debug, SIG_MSG "SIGHUP\n"); + fprintf(stderr, SIG_MSG "SIGHUP\n"); break; case SIGQUIT: - etiLog.log(debug, SIG_MSG "SIGQUIT\n"); + fprintf(stderr, SIG_MSG "SIGQUIT\n"); break; case SIGPIPE: - etiLog.log(debug, SIG_MSG "SIGPIPE\n"); + fprintf(stderr, SIG_MSG "SIGPIPE\n"); return; break; #endif case SIGINT: - etiLog.log(debug, SIG_MSG "SIGINT\n"); + fprintf(stderr, SIG_MSG "SIGINT\n"); break; case SIGTERM: - etiLog.log(debug, SIG_MSG "SIGTERM\n"); - etiLog.log(debug, "Exiting software\n"); + fprintf(stderr, SIG_MSG "SIGTERM\n"); + fprintf(stderr, "Exiting software\n"); exit(0); break; default: - etiLog.log(debug, SIG_MSG "number %i\n", signum); + fprintf(stderr, SIG_MSG "number %i\n", signum); } #ifndef _WIN32 killpg(0, SIGPIPE); -- cgit v1.2.3