diff options
author | Warren Dukes <warren.dukes@gmail.com> | 2004-04-11 01:53:25 +0000 |
---|---|---|
committer | Warren Dukes <warren.dukes@gmail.com> | 2004-04-11 01:53:25 +0000 |
commit | 12ee01660739b19fa9b0c112e6a6b266a4e2d6a8 (patch) | |
tree | ca377875b1101607907243c3bf330ad80b7018cf /src/sig_handlers.c | |
parent | 171a7752a8fab0e1c55be1469a331ef20a7b3755 (diff) | |
download | mpd-12ee01660739b19fa9b0c112e6a6b266a4e2d6a8.tar.gz mpd-12ee01660739b19fa9b0c112e6a6b266a4e2d6a8.tar.xz mpd-12ee01660739b19fa9b0c112e6a6b266a4e2d6a8.zip |
make "update" command background/non-blocking
git-svn-id: https://svn.musicpd.org/mpd/trunk@665 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to '')
-rw-r--r-- | src/sig_handlers.c | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/src/sig_handlers.c b/src/sig_handlers.c index 55296daf6..c03f7e76b 100644 --- a/src/sig_handlers.c +++ b/src/sig_handlers.c @@ -22,6 +22,10 @@ #include "directory.h" #include <signal.h> +#include <sys/types.h> +#include <sys/time.h> +#include <sys/resource.h> +#include <sys/wait.h> struct sigaction original_termSa; struct sigaction original_hupSa; @@ -41,6 +45,15 @@ void hupSigHandler(int signal) { readDirectoryDB(); } +void chldSigHandler(int signal) { + int status; + int pid = wait3(&status,WNOHANG,NULL); + if(pid>0) { + player_sigChldHandler(pid,status); + directory_sigChldHandler(pid,status); + } +} + void initSigHandlers() { struct sigaction sa; @@ -50,12 +63,14 @@ void initSigHandlers() { sigaction(SIGPIPE,&sa,NULL); sa.sa_handler = usr1SigHandler; sigaction(SIGUSR1,&sa,NULL); - sa.sa_handler = player_sigHandler; + sigaddset(&sa.sa_mask,SIGTERM); + sigaddset(&sa.sa_mask,SIGHUP); + sigaddset(&sa.sa_mask,SIGCHLD); + sa.sa_handler = chldSigHandler; sigaction(SIGCHLD,&sa,NULL); sa.sa_handler = hupSigHandler; sigaction(SIGHUP,&sa,&original_hupSa); sa.sa_handler = termSigHandler; - /*sigaddset(&sa.sa_mask,SIGTERM);*/ sigaction(SIGTERM,&sa,&original_termSa); } @@ -70,6 +85,7 @@ void blockSignals() { sigemptyset(&sset); sigaddset(&sset,SIGCHLD); sigaddset(&sset,SIGUSR1); + sigaddset(&sset,SIGHUP); sigprocmask(SIG_BLOCK,&sset,NULL); } @@ -79,6 +95,7 @@ void unblockSignals() { sigemptyset(&sset); sigaddset(&sset,SIGCHLD); sigaddset(&sset,SIGUSR1); + sigaddset(&sset,SIGHUP); sigprocmask(SIG_UNBLOCK,&sset,NULL); } @@ -87,6 +104,7 @@ void blockTermSignal() { sigemptyset(&sset); sigaddset(&sset,SIGTERM); + sigaddset(&sset,SIGHUP); sigprocmask(SIG_BLOCK,&sset,NULL); } @@ -95,5 +113,6 @@ void unblockTermSignal() { sigemptyset(&sset); sigaddset(&sset,SIGTERM); + sigaddset(&sset,SIGHUP); sigprocmask(SIG_UNBLOCK,&sset,NULL); } |