2
0
mirror of https://github.com/sudo-project/sudo.git synced 2025-08-31 06:15:37 +00:00

Implement background mode. If I/O logging we use pipes instead of a pty.

This commit is contained in:
Todd C. Miller
2010-06-09 16:19:45 -04:00
parent c5a6ca998a
commit 4c1ef12648
4 changed files with 25 additions and 11 deletions

View File

@@ -320,7 +320,8 @@ suspend_parent(int signo)
sa.sa_handler = SIG_DFL;
sigaction(signo, &sa, &osa);
sudo_debug(8, "kill parent %d", signo);
killpg(ppgrp, signo);
if (killpg(ppgrp, signo) != 0)
warning("killpg(%d, %d)", ppgrp, signo);
/* Check foreground/background status on resume. */
check_foreground();
@@ -506,7 +507,7 @@ fork_pty(struct command_details *details, char *argv[], char *envp[],
* to interpose ourselves instead of duping the pty fd.
*/
memset(io_pipe, 0, sizeof(io_pipe));
if (!isatty(STDIN_FILENO)) {
if (io_fds[SFD_STDIN] == -1 || !isatty(STDIN_FILENO)) {
pipeline = TRUE;
if (pipe(io_pipe[STDIN_FILENO]) != 0)
error(1, "unable to create pipe");
@@ -514,7 +515,7 @@ fork_pty(struct command_details *details, char *argv[], char *envp[],
log_stdin, iobufs);
io_fds[SFD_STDIN] = io_pipe[STDIN_FILENO][0];
}
if (!isatty(STDOUT_FILENO)) {
if (io_fds[SFD_STDOUT] == -1 || !isatty(STDOUT_FILENO)) {
pipeline = TRUE;
if (pipe(io_pipe[STDOUT_FILENO]) != 0)
error(1, "unable to create pipe");
@@ -522,7 +523,7 @@ fork_pty(struct command_details *details, char *argv[], char *envp[],
log_stdout, iobufs);
io_fds[SFD_STDOUT] = io_pipe[STDOUT_FILENO][1];
}
if (!isatty(STDERR_FILENO)) {
if (io_fds[SFD_STDERR] == -1 || !isatty(STDERR_FILENO)) {
if (pipe(io_pipe[STDERR_FILENO]) != 0)
error(1, "unable to create pipe");
iobufs = io_buf_new(io_pipe[STDERR_FILENO][0], STDERR_FILENO,