aboutsummaryrefslogtreecommitdiffstats
path: root/src/player.c
diff options
context:
space:
mode:
authorWarren Dukes <warren.dukes@gmail.com>2004-02-27 22:25:06 +0000
committerWarren Dukes <warren.dukes@gmail.com>2004-02-27 22:25:06 +0000
commit8b19235b6113d869fba1239ac4d1406d6d7310b8 (patch)
tree8812c98d678e1ebc53072dfb707a11214a344afc /src/player.c
parentad4246d6cb9249c1bd3865d5619d57ae0d5fd8cd (diff)
downloadmpd-8b19235b6113d869fba1239ac4d1406d6d7310b8.tar.gz
mpd-8b19235b6113d869fba1239ac4d1406d6d7310b8.tar.xz
mpd-8b19235b6113d869fba1239ac4d1406d6d7310b8.zip
put decode_pid in shared mem, so if player process dies, the master
can still kill the decode process. git-svn-id: https://svn.musicpd.org/mpd/trunk@107 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to 'src/player.c')
-rw-r--r--src/player.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/player.c b/src/player.c
index 6bc671002..e42acca18 100644
--- a/src/player.c
+++ b/src/player.c
@@ -48,6 +48,8 @@ int player_pid = 0;
int player_termSent = 0;
void resetPlayer() {
+ int pid;
+
player_pid = 0;
player_termSent = 0;
getPlayerData()->playerControl.stop = 0;
@@ -58,12 +60,17 @@ void resetPlayer() {
getPlayerData()->playerControl.state = PLAYER_STATE_STOP;
getPlayerData()->playerControl.queueState = PLAYER_QUEUE_UNLOCKED;
getPlayerData()->playerControl.seek = 0;
+ /* kill decode process if it got left running */
+ pid = getPlayerData()->playerControl.decode_pid;
+ if(pid>0) kill(pid,SIGTERM);
+ getPlayerData()->playerControl.decode_pid = 0;
}
void player_sigHandler(int signal) {
if(signal==SIGCHLD) {
int status;
- if(player_pid==wait3(&status,WNOHANG,NULL)) {
+ int pid = wait3(&status,WNOHANG,NULL);
+ if(player_pid==pid) {
if(WIFSIGNALED(status) && WTERMSIG(status)!=SIGTERM) {
ERROR("player process died from a "
"non-TERM signal: %i\n",
@@ -71,6 +78,17 @@ void player_sigHandler(int signal) {
}
resetPlayer();
}
+ else if(pid==getPlayerData()->playerControl.decode_pid &&
+ player_pid<=0)
+ {
+ if(WIFSIGNALED(status) && WTERMSIG(status)!=SIGTERM) {
+ ERROR("(caught by master parent) "
+ "decode process died from a "
+ "non-TERM signal: %i\n",
+ WTERMSIG(status));
+ }
+ getPlayerData()->playerControl.decode_pid = 0;
+ }
}
}