diff --git a/libmenu/menu_console.c b/libmenu/menu_console.c index 057c3cf763..503d25a11e 100644 --- a/libmenu/menu_console.c +++ b/libmenu/menu_console.c @@ -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; diff --git a/mplayer.c b/mplayer.c index 07c7a11646..c86425ff36 100644 --- a/mplayer.c +++ b/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: