0
0
mirror of https://github.com/mpv-player/mpv.git synced 2024-09-20 12:02:23 +02:00

handle sigchld in mplayer.c

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@13392 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
faust3 2004-09-19 18:45:11 +00:00
parent b63f5b3e85
commit a5b8e5f858
2 changed files with 21 additions and 10 deletions

View File

@ -245,15 +245,16 @@ static void check_child(menu_t* menu) {
r = select(max_fd+1,&rfd, NULL, NULL, &tv);
if(r == 0) {
r = waitpid(mpriv->child,&child_status,WNOHANG);
if(r > 0) {
printf("child died\n");
for(i = 0 ; i < 3 ; i++)
close(mpriv->child_fd[i]);
mpriv->child = 0;
mpriv->prompt = mpriv->mp_prompt;
//add_line(mpriv,"Child process exited");
} else if(r < 0)
printf("waitpid error: %s\n",strerror(errno));
if(r < 0){
if(errno==ECHILD){ ///exiting childs get handled in mplayer.c
for(i = 0 ; i < 3 ; i++)
close(mpriv->child_fd[i]);
mpriv->child = 0;
mpriv->prompt = mpriv->mp_prompt;
//add_line(mpriv,"Child process exited");
}
else printf("waitpid error: %s\n",strerror(errno));
}
} else if(r < 0) {
printf("select error\n");
return;

View File

@ -489,6 +489,13 @@ void exit_player(char* how){
exit_player_with_rc(how, 1);
}
#ifndef __MINGW32__
static void child_sighandler(int x){
pid_t pid;
while((pid=waitpid(-1,NULL,WNOHANG)) > 0);
}
#endif
static void exit_sighandler(int x){
static int sig_count=0;
++sig_count;
@ -1148,7 +1155,10 @@ current_module = NULL;
}
#endif
/// Catch signals
#ifndef __MINGW32__
signal(SIGCHLD,child_sighandler);
#endif
//========= Catch terminate signals: ================
// terminate requests: