]> granicus.if.org Git - sudo/commitdiff
We no longer need to write to the tty if the command was killed by
authorTodd C. Miller <Todd.Miller@courtesan.com>
Fri, 28 Apr 2017 16:32:15 +0000 (10:32 -0600)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Fri, 28 Apr 2017 16:32:15 +0000 (10:32 -0600)
a signal.  Sudo will terminate itself with the same signal the
command died from.  Unfortunately, we lose the "core dumped" bit
since sudo itself will not dump core, but there doesn't appear to
be a way around that.

src/exec_pty.c

index 7e12acbbfa7dc2a50065238ec955ec29841f2c27..4a05ee01249c0da01edff58aca18e088671ff6d9 100644 (file)
@@ -826,20 +826,7 @@ pty_close(struct command_status *cstat)
     if (io_fds[SFD_USERTTY] != -1)
        sudo_term_restore(io_fds[SFD_USERTTY], false);
 
-    /* If child was signalled, write the reason to stdout like the shell. */
-    if (cstat->type == CMD_WSTATUS && WIFSIGNALED(cstat->val)) {
-       int signo = WTERMSIG(cstat->val);
-       if (signo && signo != SIGINT && signo != SIGPIPE) {
-           const char *reason = strsignal(signo);
-           n = io_fds[SFD_USERTTY] != -1 ?
-               io_fds[SFD_USERTTY] : STDOUT_FILENO;
-           if (write(n, reason, strlen(reason)) != -1) {
-               if (WCOREDUMP(cstat->val))
-                   ignore_result(write(n, " (core dumped)", 14));
-               ignore_result(write(n, "\n", 1));
-           }
-       }
-    }
+    /* Update utmp */
     if (utmp_user != NULL)
        utmp_logout(slavename, cstat->type == CMD_WSTATUS ? cstat->val : 0);
     debug_return;