]> 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, 8 Dec 2011 16:15:53 +0000 (11:15 -0500)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Thu, 8 Dec 2011 16:15:53 +0000 (11:15 -0500)
the command.  Fixes a problem when the entire login session is
killed when ssh is disconnected or the terminal window is closed.
Previously, the monitor would exit and plugin's close method would
not be called.

src/exec_pty.c

index f8e59caa24e13aa3ed003b2418ce09f99d7ccd4a..29ad9775eaec0595a2c356988782b5487fea0f58 100644 (file)
@@ -888,6 +888,17 @@ exec_monitor(struct command_details *details, int backchannel)
     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.