}
}
- /* Set command timeout if specified. */
- if (ISSET(details->flags, CD_SET_TIMEOUT))
- alarm(details->timeout);
-
/*
* Child will run the command in the pty, parent will pass data
* to and from pty.
}
close(sv[1]);
+ /* Set command timeout if specified. */
+ if (ISSET(details->flags, CD_SET_TIMEOUT))
+ alarm(details->timeout);
+
/* Max fd we will be selecting on. */
maxfd = sv[0];
killpg(pid, signo);
break;
case SIGALRM:
- terminate_child(child, TRUE);
+ terminate_child(pid, TRUE);
break;
case SIGUSR1:
/* foreground process, grant it controlling tty. */
if (WIFSTOPPED(status)) {
sudo_debug(8, "command stopped, signal %d",
WSTOPSIG(status));
- } else if (WIFSIGNALED(status)) {
- sudo_debug(8, "command killed, signal %d",
- WTERMSIG(status));
} else {
- sudo_debug(8, "command exited: %d", WEXITSTATUS(status));
+ if (WIFSIGNALED(status))
+ sudo_debug(8, "command killed, signal %d",
+ WTERMSIG(status));
+ else
+ sudo_debug(8, "command exited: %d",
+ WEXITSTATUS(status));
alive = FALSE;
}
/* Send wait status unless we previously sent errno. */
error(1, "select failed");
}
- if (FD_ISSET(errpipe[0], fdsr)) {
+ if (errpipe[0] != -1 && FD_ISSET(errpipe[0], fdsr)) {
/* read errno or EOF from command pipe */
n = read(errpipe[0], &cstat, sizeof(cstat));
if (n == -1) {