From 8b19235b6113d869fba1239ac4d1406d6d7310b8 Mon Sep 17 00:00:00 2001 From: Warren Dukes Date: Fri, 27 Feb 2004 22:25:06 +0000 Subject: 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 --- src/player.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'src/player.c') 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; + } } } -- cgit v1.2.3