From: Bruno Haible Date: Mon, 10 Dec 2001 12:56:00 +0000 (+0000) Subject: Allow the caller of create_pipe_* to specify no redirection. X-Git-Tag: v0.11~217 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b1a9c6b384b2fa06cc6c6a8b4a21ecb52003bfee;p=thirdparty%2Fgettext.git Allow the caller of create_pipe_* to specify no redirection. --- diff --git a/lib/ChangeLog b/lib/ChangeLog index 27b1a708a..d8c0ec2be 100644 --- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -1,3 +1,10 @@ +2001-12-08 Bruno Haible + + * pipe-in.c (create_pipe_in): Don't redirect stdin if prog_stdin + is NULL. + * pipe-out.c (create_pipe_out): Don't redirect stdout if prog_stdout + is NULL. + 2001-11-24 Bruno Haible * javaexec.h (execute_java_class): New argument 'quiet'. diff --git a/lib/pipe-in.c b/lib/pipe-in.c index fd026f864..f08e63ba9 100644 --- a/lib/pipe-in.c +++ b/lib/pipe-in.c @@ -106,7 +106,7 @@ nonintr_open (pathname, oflag, mode) /* Open a pipe for input from a child process. - * The child's stdin comes to a file. + * The child's stdin comes from a file. * * read system write * parent <- fd[0] <- STDOUT_FILENO <- child @@ -154,10 +154,12 @@ create_pipe_in (progname, prog_path, prog_argv, prog_stdin, null_stderr, exit_on "/dev/null", O_RDWR, 0)) != 0) - || (err = posix_spawn_file_actions_addopen (&actions, - STDIN_FILENO, - prog_stdin, O_RDONLY, - 0)) != 0 + || (prog_stdin != NULL + && (err = posix_spawn_file_actions_addopen (&actions, + STDIN_FILENO, + prog_stdin, O_RDONLY, + 0)) + != 0) || (err = posix_spawnp (&child, prog_path, &actions, NULL, prog_argv, environ)) != 0)) { @@ -189,10 +191,11 @@ create_pipe_in (progname, prog_path, prog_argv, prog_stdin, null_stderr, exit_on && (nulloutfd == STDERR_FILENO || (dup2 (nulloutfd, STDERR_FILENO) >= 0 && close (nulloutfd) >= 0)))) - && (stdinfd = open (prog_stdin, O_RDONLY, 0)) >= 0 - && (stdinfd == STDIN_FILENO - || (dup2 (stdinfd, STDIN_FILENO) >= 0 - && close (stdinfd) >= 0))) + && (prog_stdin == NULL + || ((stdinfd = open (prog_stdin, O_RDONLY, 0)) >= 0 + && (stdinfd == STDIN_FILENO + || (dup2 (stdinfd, STDIN_FILENO) >= 0 + && close (stdinfd) >= 0))))) execvp (prog_path, prog_argv); _exit (127); } diff --git a/lib/pipe-out.c b/lib/pipe-out.c index d797bf0ca..fb16881f4 100644 --- a/lib/pipe-out.c +++ b/lib/pipe-out.c @@ -154,10 +154,12 @@ create_pipe_out (progname, prog_path, prog_argv, prog_stdout, null_stderr, exit_ "/dev/null", O_RDWR, 0)) != 0) - || (err = posix_spawn_file_actions_addopen (&actions, - STDOUT_FILENO, - prog_stdout, O_WRONLY, - 0)) != 0 + || (prog_stdout != NULL + && (err = posix_spawn_file_actions_addopen (&actions, + STDOUT_FILENO, + prog_stdout, O_WRONLY, + 0)) + != 0) || (err = posix_spawnp (&child, prog_path, &actions, NULL, prog_argv, environ)) != 0)) { @@ -189,10 +191,11 @@ create_pipe_out (progname, prog_path, prog_argv, prog_stdout, null_stderr, exit_ && (nulloutfd == STDERR_FILENO || (dup2 (nulloutfd, STDERR_FILENO) >= 0 && close (nulloutfd) >= 0)))) - && (stdoutfd = open (prog_stdout, O_WRONLY, 0)) >= 0 - && (stdoutfd == STDOUT_FILENO - || (dup2 (stdoutfd, STDOUT_FILENO) >= 0 - && close (stdoutfd) >= 0))) + && (prog_stdout == NULL + || ((stdoutfd = open (prog_stdout, O_WRONLY, 0)) >= 0 + && (stdoutfd == STDOUT_FILENO + || (dup2 (stdoutfd, STDOUT_FILENO) >= 0 + && close (stdoutfd) >= 0))))) execvp (prog_path, prog_argv); _exit (127); } diff --git a/lib/pipe.h b/lib/pipe.h index c972950a7..528a3c2cb 100644 --- a/lib/pipe.h +++ b/lib/pipe.h @@ -60,7 +60,7 @@ extern pid_t create_pipe_out PARAMS ((const char *progname, int fd[1])); /* Open a pipe for input from a child process. - * The child's stdin comes to a file. + * The child's stdin comes from a file. * * read system write * parent <- fd[0] <- STDOUT_FILENO <- child