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.
This commit is contained in:
Todd C. Miller
2010-03-31 12:43:26 -04:00
parent 8cde6d699e
commit c3e87c2db3

View File

@@ -339,10 +339,6 @@ script_execve(struct command_details *details, char *argv[], char *envp[],
sigemptyset(&sa.sa_mask); sigemptyset(&sa.sa_mask);
sa.sa_flags = SA_RESTART; 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 */ /* Catch SIGALRM for command timeout */
sa.sa_handler = handler; sa.sa_handler = handler;
sigaction(SIGALRM, &sa, NULL); sigaction(SIGALRM, &sa, NULL);
@@ -351,6 +347,11 @@ script_execve(struct command_details *details, char *argv[], char *envp[],
sa.sa_handler = SIG_IGN; sa.sa_handler = SIG_IGN;
sigaction(SIGPIPE, &sa, NULL); 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) { if (log_io) {
sa.sa_handler = sigwinch; sa.sa_handler = sigwinch;
sigaction(SIGWINCH, &sa, NULL); 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(SIGTTIN, &sa, NULL);
sigaction(SIGTTOU, &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; sa.sa_handler = handler;
sigaction(SIGCHLD, &sa, NULL); 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(SIGTTOU, &sa, NULL);
sigaction(SIGUSR1, &sa, NULL); sigaction(SIGUSR1, &sa, NULL);
sigaction(SIGUSR2, &sa, NULL); sigaction(SIGUSR2, &sa, NULL);
sigaction(SIGCHLD, &sa, NULL);
/* setup tty and exec command */ /* setup tty and exec command */
script_run(path, argv, envp, rbac); script_run(path, argv, envp, rbac);