]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
Allow the caller of create_pipe_* to specify no redirection.
authorBruno Haible <bruno@clisp.org>
Mon, 10 Dec 2001 12:56:00 +0000 (12:56 +0000)
committerBruno Haible <bruno@clisp.org>
Sun, 21 Jun 2009 21:36:50 +0000 (23:36 +0200)
lib/ChangeLog
lib/pipe-in.c
lib/pipe-out.c
lib/pipe.h

index 27b1a708a36731888a4c6dbe36881384e6a1d995..d8c0ec2be2e849c01cd9da716bf983383c85d29c 100644 (file)
@@ -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'.
index fd026f864bb698eb032764cb7a02f75b35ce0ef9..f08e63ba99ddf896ad4ec23dbea37a6dc675f363 100644 (file)
@@ -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);
     }
index d797bf0cabfb3dd144f72ac41e4ab7add372d811..fb16881f4181030094fd1363e7ab2b687160b6fe 100644 (file)
@@ -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);
     }
index c972950a719d0f4a78453439cdad6aa7777c501c..528a3c2cb56f6a19e689be2d3dc0ba404d0a91ae 100644 (file)
@@ -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