]> granicus.if.org Git - sudo/commitdiff
Unlike most operating systems, HP-UX select() is not interrupted
authorTodd C. Miller <Todd.Miller@courtesan.com>
Wed, 31 Mar 2010 16:43:26 +0000 (12:43 -0400)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Wed, 31 Mar 2010 16:43:26 +0000 (12:43 -0400)
by SIGCHLD when the signal is registered with SA_RESTART.  If
we clear SA_RESTART when calling sigaction() for SIGCHLD we get
the expected behavior and the code in the select() loops already
handles EINTR correctly.

src/script.c

index dd777aab13cbdf7d67160a7fec9ab9bc5cb53d9a..3962e45d48299fd27630035607d94c6ba012c579 100644 (file)
@@ -339,10 +339,6 @@ script_execve(struct command_details *details, char *argv[], char *envp[],
     sigemptyset(&sa.sa_mask);
     sa.sa_flags = SA_RESTART;
 
-    /* XXX - now get command status via sv (still need to detect child death) */
-    sa.sa_handler = sigchild;
-    sigaction(SIGCHLD, &sa, NULL);
-
     /* Catch SIGALRM for command timeout */
     sa.sa_handler = handler;
     sigaction(SIGALRM, &sa, NULL);
@@ -351,6 +347,11 @@ script_execve(struct command_details *details, char *argv[], char *envp[],
     sa.sa_handler = SIG_IGN;
     sigaction(SIGPIPE, &sa, NULL);
 
+    /* Note: HP-UX select() will not be interrupted if SA_RESTART set */
+    sa.sa_flags = 0;
+    sa.sa_handler = sigchild;
+    sigaction(SIGCHLD, &sa, NULL);
+
     if (log_io) {
        sa.sa_handler = sigwinch;
        sigaction(SIGWINCH, &sa, NULL);
@@ -724,7 +725,8 @@ script_child(const char *path, char *argv[], char *envp[], int backchannel, int
     sigaction(SIGTTIN, &sa, NULL);
     sigaction(SIGTTOU, &sa, NULL);
 
-    /* SIGCHLD will interrupt select. */
+    /* Note: HP-UX select() will not be interrupted if SA_RESTART set */
+    sa.sa_flags = 0;
     sa.sa_handler = handler;
     sigaction(SIGCHLD, &sa, NULL);
 
@@ -782,6 +784,7 @@ script_child(const char *path, char *argv[], char *envp[], int backchannel, int
        sigaction(SIGTTOU, &sa, NULL);
        sigaction(SIGUSR1, &sa, NULL);
        sigaction(SIGUSR2, &sa, NULL);
+       sigaction(SIGCHLD, &sa, NULL);
 
        /* setup tty and exec command */
        script_run(path, argv, envp, rbac);