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
This commit is contained in:
Warren Dukes
2004-02-27 22:25:06 +00:00
parent ad4246d6cb
commit 8b19235b61
4 changed files with 43 additions and 18 deletions

View File

@@ -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;
}
}
}