Commit 6a77e60c authored by Warren Dukes's avatar Warren Dukes

now player and decoder processes should only exit() when receiving term signal…

now player and decoder processes should only exit() when receiving term signal from their respective parent processes git-svn-id: https://svn.musicpd.org/mpd/trunk@3034 09075e82-0dd4-0310-85a5-a0d7c8717e4f
parent 3764b060
......@@ -284,7 +284,7 @@ static int alsa_playAudio(AudioOutput * audioOutput, char * playChunk,
while (size > 0) {
ret = ad->writei(ad->pcmHandle, playChunk, size);
if(ret == -EAGAIN) continue;
if(ret == -EAGAIN || ret == -EINTR) continue;
if(ret < 0) {
if( alsa_errorRecovery(ad, ret) < 0) {
......
......@@ -39,7 +39,7 @@
volatile int * volatile decode_pid = NULL;
void decodeSigHandler(int sig) {
void decodeSigHandler(int sig, siginfo_t * si, void * v) {
if(sig==SIGCHLD) {
int status;
if(decode_pid && *decode_pid==wait3(&status,WNOHANG,NULL)) {
......@@ -52,7 +52,8 @@ void decodeSigHandler(int sig) {
*decode_pid = 0;
}
}
else if(sig==SIGTERM) {
else if(sig==SIGTERM && si->si_pid==getppid()) {
DEBUG("player/decoder got SIGTERM from parent process\n");
if(decode_pid) {
int pid = *decode_pid;
if(pid>0) kill(pid,SIGTERM);
......
......@@ -27,6 +27,7 @@
#include <stdio.h>
#include <sys/param.h>
#include <signal.h>
#define DECODE_TYPE_FILE 0
#define DECODE_TYPE_URL 1
......@@ -61,7 +62,7 @@ typedef struct _DecoderControl {
volatile float totalTime;
} DecoderControl;
void decodeSigHandler(int sig);
void decodeSigHandler(int sig, siginfo_t * siginfo, void * v);
void decode();
......
......@@ -74,6 +74,7 @@ void initSigHandlers() {
sa.sa_flags = 0;
sigemptyset(&sa.sa_mask);
sa.sa_handler = SIG_IGN;
sa.sa_sigaction = NULL;
while(sigaction(SIGPIPE,&sa,NULL)<0 && errno==EINTR);
sa.sa_handler = chldSigHandler;
while(sigaction(SIGCHLD,&sa,NULL)<0 && errno==EINTR);
......@@ -98,8 +99,11 @@ void setSigHandlersForDecoder() {
sa.sa_flags = 0;
sigemptyset(&sa.sa_mask);
sa.sa_handler = SIG_IGN;
sa.sa_sigaction = NULL;
while(sigaction(SIGHUP,&sa,NULL)<0 && errno==EINTR);
sa.sa_handler = decodeSigHandler;
sa.sa_handler = NULL;
sa.sa_flags = SA_SIGINFO;
sa.sa_sigaction = 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);
......@@ -111,6 +115,7 @@ void ignoreSignals() {
sa.sa_flags = 0;
sigemptyset(&sa.sa_mask);
sa.sa_handler = SIG_IGN;
sa.sa_sigaction = NULL;
while(sigaction(SIGPIPE,&sa,NULL)<0 && errno==EINTR);
while(sigaction(SIGCHLD,&sa,NULL)<0 && errno==EINTR);
while(sigaction(SIGUSR1,&sa,NULL)<0 && errno==EINTR);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment