Exemple #1
0
void
sigchld_handler (int sig)
{
    int status;
    pid_t pid;

    (void) sig;

    pid = waitpid (subshell_pid, &status, WUNTRACED | WNOHANG);

    if (pid == subshell_pid)
    {
        /* Figure out what has happened to the subshell */

        if (WIFSTOPPED (status))
        {
            if (WSTOPSIG (status) == SIGSTOP)
            {
                /* The subshell has received a SIGSTOP signal */
                subshell_stopped = TRUE;
            }
            else
            {
                /* The user has suspended the subshell.  Revive it */
                kill (subshell_pid, SIGCONT);
            }
        }
        else
        {
            /* The subshell has either exited normally or been killed */
            subshell_alive = FALSE;
            delete_select_channel (mc_global.tty.subshell_pty);
            if (WIFEXITED (status) && WEXITSTATUS (status) != FORK_FAILURE)
                quit |= SUBSHELL_EXIT;  /* Exited normally */
        }
    }
#ifdef __linux__
    pid = waitpid (cons_saver_pid, &status, WUNTRACED | WNOHANG);

    if (pid == cons_saver_pid)
    {

        if (WIFSTOPPED (status))
            /* Someone has stopped cons.saver - restart it */
            kill (pid, SIGCONT);
        else
        {
            /* cons.saver has died - disable confole saving */
            handle_console (CONSOLE_DONE);
            mc_global.tty.console_flag = '\0';
        }

    }
#endif /* __linux__ */

    /* If we got here, some other child exited; ignore it */
}
Exemple #2
0
void
sigchld_handler (int sig)
{
    int status;
    pid_t pid;

    (void) sig;

    pid = waitpid (subshell_pid, &status, WUNTRACED | WNOHANG);

    if (pid == subshell_pid)
    {
        /* Figure out what has happened to the subshell */

        if (WIFSTOPPED (status))
        {
            if (WSTOPSIG (status) == SIGSTOP)
            {
                /* The subshell has received a SIGSTOP signal */
                subshell_stopped = TRUE;
            }
            else
            {
                /* The user has suspended the subshell.  Revive it */
                kill (subshell_pid, SIGCONT);
            }
        }
        else
        {
            /* The subshell has either exited normally or been killed */
            subshell_alive = FALSE;
            delete_select_channel (mc_global.tty.subshell_pty);
            if (WIFEXITED (status) && WEXITSTATUS (status) != FORK_FAILURE)
            {
                int subshell_quit;
                subshell_quit = subshell_get_mainloop_quit () | SUBSHELL_EXIT;  /* Exited normally */
                subshell_set_mainloop_quit (subshell_quit);
            }
        }
    }
    subshell_handle_cons_saver ();

    /* If we got here, some other child exited; ignore it */
}