mirror of
https://github.com/mpv-player/mpv
synced 2024-12-18 04:45:33 +00: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:
parent
b63f5b3e85
commit
a5b8e5f858
@ -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");
|
||||
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 if(r < 0)
|
||||
printf("waitpid error: %s\n",strerror(errno));
|
||||
}
|
||||
else printf("waitpid error: %s\n",strerror(errno));
|
||||
}
|
||||
} else if(r < 0) {
|
||||
printf("select error\n");
|
||||
return;
|
||||
|
12
mplayer.c
12
mplayer.c
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user