summaryrefslogtreecommitdiffstats
path: root/src/DabMux.cpp
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2016-10-03 20:33:20 +0200
committerMatthias P. Braendli <matthias.braendli@mpb.li>2016-10-03 20:33:20 +0200
commit8cec95b777f9e52efceb558f47804572b9752b88 (patch)
treeca4600498c6f70a725dc83fb64e089914f885c0b /src/DabMux.cpp
parent369874e1c38680d27f187aa0297b0ce00b3f9fa0 (diff)
downloaddabmux-8cec95b777f9e52efceb558f47804572b9752b88.tar.gz
dabmux-8cec95b777f9e52efceb558f47804572b9752b88.tar.bz2
dabmux-8cec95b777f9e52efceb558f47804572b9752b88.zip
Avoid deadlock on receiving signal
Diffstat (limited to 'src/DabMux.cpp')
-rw-r--r--src/DabMux.cpp21
1 files changed, 12 insertions, 9 deletions
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);