diff options
author | Qball Cow <qball@qballcow.nl> | 2005-11-18 12:09:05 +0000 |
---|---|---|
committer | Qball Cow <qball@qballcow.nl> | 2005-11-18 12:09:05 +0000 |
commit | 4b00c62587dbe0ce131992dcd574ffe323cffa5c (patch) | |
tree | 231924d4c2fb4eb916c3a02ed1fc505e42081e58 /src/sig_handlers.c | |
parent | 32e5f4ca2b43c310ff6639320dec2dd52f159f50 (diff) | |
download | mpd-4b00c62587dbe0ce131992dcd574ffe323cffa5c.tar.gz mpd-4b00c62587dbe0ce131992dcd574ffe323cffa5c.tar.xz mpd-4b00c62587dbe0ce131992dcd574ffe323cffa5c.zip |
DJWLindenaar's fix race condition and some memory leaks patch
git-svn-id: https://svn.musicpd.org/mpd/trunk@3681 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to '')
-rw-r--r-- | src/sig_handlers.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/sig_handlers.c b/src/sig_handlers.c index 364636e7c..567a39133 100644 --- a/src/sig_handlers.c +++ b/src/sig_handlers.c @@ -56,7 +56,17 @@ int masterHandlePendingSignals() { } int handlePendingSignals() { - if(signal_is_pending(SIGINT) || signal_is_pending(SIGTERM)) { + /* this SIGUSR1 signal comes before the KILL signals, because there if the process is + * looping, waiting for this signal, it will not respond to the KILL signal. This might be + * better implemented by using bit-wise defines and or'ing of the COMMAND_FOO as return. + */ + if (signal_is_pending(SIGUSR1)) { + signal_clear(SIGUSR1); + DEBUG("The master process is ready to receive signals\n"); + return COMMAND_MASTER_READY; + } + + if(signal_is_pending(SIGINT) || signal_is_pending(SIGTERM)) { DEBUG("main process got SIGINT or SIGTERM, exiting\n"); return COMMAND_RETURN_KILL; } @@ -135,6 +145,7 @@ void initSigHandlers() { while(sigaction(SIGPIPE,&sa,NULL)<0 && errno==EINTR); sa.sa_handler = chldSigHandler; while(sigaction(SIGCHLD,&sa,NULL)<0 && errno==EINTR); + signal_handle(SIGUSR2); signal_handle(SIGUSR1); signal_handle(SIGINT); signal_handle(SIGTERM); |