From c5ce5f3c01af95093aea122a3be2b40288ab94e4 Mon Sep 17 00:00:00 2001 From: Warren Dukes Date: Wed, 3 Nov 2004 14:29:37 +0000 Subject: new setSigHandlersForDecoder() function, and be sure player/decode processes ignore SIGHUP signals git-svn-id: https://svn.musicpd.org/mpd/trunk@2492 09075e82-0dd4-0310-85a5-a0d7c8717e4f --- TODO | 4 ---- src/player.c | 10 +--------- src/sig_handlers.c | 16 ++++++++++++++++ src/sig_handlers.h | 2 ++ 4 files changed, 19 insertions(+), 13 deletions(-) diff --git a/TODO b/TODO index 68aefc8e3..50daa1130 100644 --- a/TODO +++ b/TODO @@ -11,10 +11,6 @@ *) command for displaying playlist contents *) command for appending to playlist -*) use getaddrinfo instead of gethostbyname (check libshout) - -*) have children ignore SIGHUP - *) put more debugging info when failing to read/write db and other similar errors diff --git a/src/player.c b/src/player.c index f38b9384c..cb9b5ed1c 100644 --- a/src/player.c +++ b/src/player.c @@ -105,20 +105,12 @@ int playerInit() { player_pid = fork(); if(player_pid==0) { PlayerControl * pc = &(getPlayerData()->playerControl); - struct sigaction sa; clearUpdatePid(); unblockSignals(); - sa.sa_flags = 0; - sigemptyset(&sa.sa_mask); - - finishSigHandlers(); - sa.sa_handler = decodeSigHandler; - while(sigaction(SIGCHLD,&sa,NULL)<0 && errno==EINTR); - while(sigaction(SIGTERM,&sa,NULL)<0 && errno==EINTR); - while(sigaction(SIGINT,&sa,NULL)<0 && errno==EINTR); + setSigHandlersForDecoder(); while(close(listenSocket)<0 && errno==EINTR); freeAllInterfaces(); diff --git a/src/sig_handlers.c b/src/sig_handlers.c index a3ac478cb..4ab5163bf 100644 --- a/src/sig_handlers.c +++ b/src/sig_handlers.c @@ -25,6 +25,7 @@ #include "signal_check.h" #include "log.h" #include "player.h" +#include "decode.h" #include #include @@ -89,6 +90,21 @@ void finishSigHandlers() { signal_unhandle(SIGHUP); } +void setSigHandlersForDecoder() { + struct sigaction sa; + + finishSigHandlers(); + + sa.sa_flags = 0; + sigemptyset(&sa.sa_mask); + sa.sa_handler = SIG_IGN; + while(sigaction(SIGHUP,&sa,NULL)<0 && errno==EINTR); + sa.sa_handler = decodeSigHandler; + while(sigaction(SIGCHLD,&sa,NULL)<0 && errno==EINTR); + while(sigaction(SIGTERM,&sa,NULL)<0 && errno==EINTR); + while(sigaction(SIGINT,&sa,NULL)<0 && errno==EINTR); +} + void ignoreSignals() { struct sigaction sa; diff --git a/src/sig_handlers.h b/src/sig_handlers.h index 70f2fc4ad..e1293060b 100644 --- a/src/sig_handlers.h +++ b/src/sig_handlers.h @@ -27,6 +27,8 @@ void initSigHandlers(); void finishSigHandlers(); +void setSigHandlersForDecoder(); + void ignoreSignals(); void blockSignals(); -- cgit v1.2.3