From: Todd C. Miller Date: Wed, 31 Mar 2010 16:43:26 +0000 (-0400) Subject: Unlike most operating systems, HP-UX select() is not interrupted X-Git-Tag: SUDO_1_8_0~758 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c3e87c2db373dce439f8f66f0a5d6f2a4249c1e1;p=sudo Unlike most operating systems, HP-UX select() is not interrupted 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. --- diff --git a/src/script.c b/src/script.c index dd777aab1..3962e45d4 100644 --- a/src/script.c +++ b/src/script.c @@ -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);