When a terminal device is closed, SIGHUP is sent to the controlling

process associated with that terminal.  It is not sent to the entire
process group so sudo needs to relay SIGHUP to the command when it
is not being run in a new pty.  Bug #719
This commit is contained in:
Todd C. Miller
2015-09-15 10:30:36 -06:00
parent b12500993d
commit 3f6f1cd15c

View File

@@ -407,6 +407,8 @@ sudo_execute(struct command_details *details, struct command_status *cstat)
#endif #endif
if (sudo_sigaction(SIGTERM, &sa, NULL) != 0) if (sudo_sigaction(SIGTERM, &sa, NULL) != 0)
sudo_warn(U_("unable to set handler for signal %d"), SIGTERM); sudo_warn(U_("unable to set handler for signal %d"), SIGTERM);
if (sudo_sigaction(SIGHUP, &sa, NULL) != 0)
sudo_warn(U_("unable to set handler for signal %d"), SIGHUP);
if (sudo_sigaction(SIGALRM, &sa, NULL) != 0) if (sudo_sigaction(SIGALRM, &sa, NULL) != 0)
sudo_warn(U_("unable to set handler for signal %d"), SIGALRM); sudo_warn(U_("unable to set handler for signal %d"), SIGALRM);
if (sudo_sigaction(SIGPIPE, &sa, NULL) != 0) if (sudo_sigaction(SIGPIPE, &sa, NULL) != 0)
@@ -424,8 +426,7 @@ sudo_execute(struct command_details *details, struct command_status *cstat)
* When not running the command in a pty, we do not want to * When not running the command in a pty, we do not want to
* forward signals generated by the kernel that the child will * forward signals generated by the kernel that the child will
* already have received either by virtue of being in the * already have received either by virtue of being in the
* controlling tty's process group (SIGINT, SIGQUIT) or because * controlling tty's process group (SIGINT, SIGQUIT).
* the session is terminating (SIGHUP).
*/ */
#ifdef SA_SIGINFO #ifdef SA_SIGINFO
if (!log_io) { if (!log_io) {
@@ -433,8 +434,6 @@ sudo_execute(struct command_details *details, struct command_status *cstat)
sa.sa_sigaction = handler_user_only; sa.sa_sigaction = handler_user_only;
} }
#endif #endif
if (sudo_sigaction(SIGHUP, &sa, NULL) != 0)
sudo_warn(U_("unable to set handler for signal %d"), SIGHUP);
if (sudo_sigaction(SIGINT, &sa, NULL) != 0) if (sudo_sigaction(SIGINT, &sa, NULL) != 0)
sudo_warn(U_("unable to set handler for signal %d"), SIGINT); sudo_warn(U_("unable to set handler for signal %d"), SIGINT);
if (sudo_sigaction(SIGQUIT, &sa, NULL) != 0) if (sudo_sigaction(SIGQUIT, &sa, NULL) != 0)