mirror of
https://github.com/mpv-player/mpv
synced 2024-12-18 21:06:00 +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);
|
r = select(max_fd+1,&rfd, NULL, NULL, &tv);
|
||||||
if(r == 0) {
|
if(r == 0) {
|
||||||
r = waitpid(mpriv->child,&child_status,WNOHANG);
|
r = waitpid(mpriv->child,&child_status,WNOHANG);
|
||||||
if(r > 0) {
|
if(r < 0){
|
||||||
printf("child died\n");
|
if(errno==ECHILD){ ///exiting childs get handled in mplayer.c
|
||||||
for(i = 0 ; i < 3 ; i++)
|
for(i = 0 ; i < 3 ; i++)
|
||||||
close(mpriv->child_fd[i]);
|
close(mpriv->child_fd[i]);
|
||||||
mpriv->child = 0;
|
mpriv->child = 0;
|
||||||
mpriv->prompt = mpriv->mp_prompt;
|
mpriv->prompt = mpriv->mp_prompt;
|
||||||
//add_line(mpriv,"Child process exited");
|
//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) {
|
} else if(r < 0) {
|
||||||
printf("select error\n");
|
printf("select error\n");
|
||||||
return;
|
return;
|
||||||
|
12
mplayer.c
12
mplayer.c
@ -489,6 +489,13 @@ void exit_player(char* how){
|
|||||||
exit_player_with_rc(how, 1);
|
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 void exit_sighandler(int x){
|
||||||
static int sig_count=0;
|
static int sig_count=0;
|
||||||
++sig_count;
|
++sig_count;
|
||||||
@ -1148,7 +1155,10 @@ current_module = NULL;
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/// Catch signals
|
||||||
|
#ifndef __MINGW32__
|
||||||
|
signal(SIGCHLD,child_sighandler);
|
||||||
|
#endif
|
||||||
|
|
||||||
//========= Catch terminate signals: ================
|
//========= Catch terminate signals: ================
|
||||||
// terminate requests:
|
// terminate requests:
|
||||||
|
Loading…
Reference in New Issue
Block a user