diff options
author | Bruno Haible <bruno@clisp.org> | 2001-12-10 12:56:00 +0000 |
---|---|---|
committer | Bruno Haible <bruno@clisp.org> | 2009-06-21 23:36:50 +0200 |
commit | b1a9c6b384b2fa06cc6c6a8b4a21ecb52003bfee (patch) | |
tree | 5e469cf76d677cb9e11cce9755fb8841abc9924e /lib | |
parent | 2a500dbb7cb740301b109534b219c9692fd9add3 (diff) | |
download | external_gettext-b1a9c6b384b2fa06cc6c6a8b4a21ecb52003bfee.zip external_gettext-b1a9c6b384b2fa06cc6c6a8b4a21ecb52003bfee.tar.gz external_gettext-b1a9c6b384b2fa06cc6c6a8b4a21ecb52003bfee.tar.bz2 |
Allow the caller of create_pipe_* to specify no redirection.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/ChangeLog | 7 | ||||
-rw-r--r-- | lib/pipe-in.c | 21 | ||||
-rw-r--r-- | lib/pipe-out.c | 19 | ||||
-rw-r--r-- | lib/pipe.h | 2 |
4 files changed, 31 insertions, 18 deletions
diff --git a/lib/ChangeLog b/lib/ChangeLog index 27b1a70..d8c0ec2 100644 --- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -1,3 +1,10 @@ +2001-12-08 Bruno Haible <bruno@clisp.org> + + * 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 <bruno@clisp.org> * javaexec.h (execute_java_class): New argument 'quiet'. diff --git a/lib/pipe-in.c b/lib/pipe-in.c index fd026f8..f08e63b 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 d797bf0..fb16881 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); } @@ -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 |