]> granicus.if.org Git - sudo/commitdiff
Catch common signals in the monitor process so they get passed to
authorTodd C. Miller <Todd.Miller@courtesan.com>
Thu, 12 Jan 2012 19:52:07 +0000 (14:52 -0500)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Thu, 12 Jan 2012 19:52:07 +0000 (14:52 -0500)
the command. Fixes a problem when the entire login session is killed
when ssh is disconnected or the terminal window is closed.

--HG--
branch : 1.7

exec_pty.c

index 37c4e31bd4e25d4e27fd574db511cf4af093b99c..7a47ccb70275803fe8b9ad03da6f1e0cc8f47695 100644 (file)
@@ -733,6 +733,17 @@ exec_monitor(path, argv, envp, backchannel, rbac)
     sa.sa_handler = handler;
     sigaction(SIGCHLD, &sa, NULL);
 
+    /* Catch common signals so we can cleanup properly. */
+    sa.sa_flags = SA_RESTART;
+    sa.sa_handler = handler;
+    sigaction(SIGHUP, &sa, NULL);
+    sigaction(SIGINT, &sa, NULL);
+    sigaction(SIGQUIT, &sa, NULL);
+    sigaction(SIGTERM, &sa, NULL);
+    sigaction(SIGTSTP, &sa, NULL);
+    sigaction(SIGUSR1, &sa, NULL);
+    sigaction(SIGUSR2, &sa, NULL);
+
     /*
      * Start a new session with the parent as the session leader
      * and the slave pty as the controlling terminal.