]> granicus.if.org Git - sudo/commitdiff
No need to restore default signal handler for SIGSTOP as it is not
authorTodd C. Miller <Todd.Miller@courtesan.com>
Fri, 28 Dec 2012 16:03:23 +0000 (11:03 -0500)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Fri, 28 Dec 2012 16:03:23 +0000 (11:03 -0500)
catchable.  Attempting to do so is harmless but sigaction() will
fail and set errno to EINVAL which makes it looks like there is an
error.

src/exec_pty.c

index 403928360de480062362c59f5acf357e4fd0d731..a80dbb20d908fd461522e1ee0262464d1d253389 100644 (file)
@@ -388,11 +388,13 @@ suspend_parent(int signo)
            snprintf(signame, sizeof(signame), "%d", signo);
 
        /* Suspend self and continue command when we resume. */
-       zero_bytes(&sa, sizeof(sa));
-       sigemptyset(&sa.sa_mask);
-       sa.sa_flags = SA_INTERRUPT; /* do not restart syscalls */
-       sa.sa_handler = SIG_DFL;
-       sigaction(signo, &sa, &osa);
+       if (signo != SIGSTOP) {
+           zero_bytes(&sa, sizeof(sa));
+           sigemptyset(&sa.sa_mask);
+           sa.sa_flags = SA_INTERRUPT; /* do not restart syscalls */
+           sa.sa_handler = SIG_DFL;
+           sigaction(signo, &sa, &osa);
+       }
        sudo_debug_printf(SUDO_DEBUG_INFO, "kill parent SIG%s", signame);
        if (killpg(ppgrp, signo) != 0)
            warning("killpg(%d, SIG%s)", (int)ppgrp, signame);
@@ -419,7 +421,8 @@ suspend_parent(int signo)
            }
        }
 
-       sigaction(signo, &osa, NULL);
+       if (signo != SIGSTOP)
+           sigaction(signo, &osa, NULL);
        rval = ttymode == TERM_RAW ? SIGCONT_FG : SIGCONT_BG;
        break;
     }