Mercurial > hg > octave-nkf > gnulib-hg
annotate lib/spawn-pipe.h @ 16040:b8acd8099b25
New module 'fmaf'.
* lib/math.in.h (fmaf): New declaration.
* lib/fmaf.c: New file.
* m4/fmaf.m4: New file.
* m4/math_h.m4 (gl_MATH_H): Test whethern fmaf is declared.
(gl_MATH_H_DEFAULTS): Initialize GNULIB_FMAF, HAVE_FMAF, REPLACE_FMAF.
* modules/math (Makefile.am): Substitute GNULIB_FMAF, HAVE_FMAF,
REPLACE_FMAF.
* modules/fmaf: New file.
* doc/posix-functions/fmaf.texi: Mention the new module and the various
bugs.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Mon, 17 Oct 2011 23:51:21 +0200 |
parents | 97fc9a21a8fb |
children | 8250f2777afc |
rev | line source |
---|---|
13924
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
1 /* Creation of subprocesses, communicating via pipes. |
14079
97fc9a21a8fb
maint: update almost all copyright ranges to include 2011
Jim Meyering <meyering@redhat.com>
parents:
13924
diff
changeset
|
2 Copyright (C) 2001-2003, 2006, 2008-2011 Free Software Foundation, Inc. |
13924
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
3 Written by Bruno Haible <haible@clisp.cons.org>, 2001. |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
4 |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
5 This program is free software: you can redistribute it and/or modify |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
6 it under the terms of the GNU General Public License as published by |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
7 the Free Software Foundation; either version 3 of the License, or |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
8 (at your option) any later version. |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
9 |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
10 This program is distributed in the hope that it will be useful, |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
11 but WITHOUT ANY WARRANTY; without even the implied warranty of |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
13 GNU General Public License for more details. |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
14 |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
15 You should have received a copy of the GNU General Public License |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
17 |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
18 #ifndef _SPAWN_PIPE_H |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
19 #define _SPAWN_PIPE_H |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
20 |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
21 /* Get pid_t. */ |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
22 #include <stdlib.h> |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
23 #include <unistd.h> |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
24 #include <sys/types.h> |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
25 |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
26 #include <stdbool.h> |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
27 |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
28 |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
29 #ifdef __cplusplus |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
30 extern "C" { |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
31 #endif |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
32 |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
33 |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
34 /* All these functions create a subprocess and don't wait for its termination. |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
35 They return the process id of the subprocess. They also return in fd[] |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
36 one or two file descriptors for communication with the subprocess. |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
37 If the subprocess creation fails: if exit_on_error is true, the main |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
38 process exits with an error message; otherwise, an error message is given |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
39 if null_stderr is false, then -1 is returned, with errno set, and fd[] |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
40 remain uninitialized. |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
41 |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
42 After finishing communication, the caller should call wait_subprocess() |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
43 to get rid of the subprocess in the process table. |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
44 |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
45 If slave_process is true, the child process will be terminated when its |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
46 creator receives a catchable fatal signal or exits normally. If |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
47 slave_process is false, the child process will continue running in this |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
48 case, until it is lucky enough to attempt to communicate with its creator |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
49 and thus get a SIGPIPE signal. |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
50 |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
51 If exit_on_error is false, a child process id of -1 should be treated the |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
52 same way as a subprocess which accepts no input, produces no output and |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
53 terminates with exit code 127. Why? Some errors during posix_spawnp() |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
54 cause the function posix_spawnp() to return an error code; some other |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
55 errors cause the subprocess to exit with return code 127. It is |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
56 implementation dependent which error is reported which way. The caller |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
57 must treat both cases as equivalent. |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
58 |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
59 It is recommended that no signal is blocked or ignored (i.e. have a |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
60 signal handler with value SIG_IGN) while any of these functions is called. |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
61 The reason is that child processes inherit the mask of blocked signals |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
62 from their parent (both through posix_spawn() and fork()/exec()); |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
63 likewise, signals ignored in the parent are also ignored in the child |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
64 (except possibly for SIGCHLD). And POSIX:2001 says [in the description |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
65 of exec()]: |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
66 "it should be noted that many existing applications wrongly |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
67 assume that they start with certain signals set to the default |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
68 action and/or unblocked. In particular, applications written |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
69 with a simpler signal model that does not include blocking of |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
70 signals, such as the one in the ISO C standard, may not behave |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
71 properly if invoked with some signals blocked. Therefore, it is |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
72 best not to block or ignore signals across execs without explicit |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
73 reason to do so, and especially not to block signals across execs |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
74 of arbitrary (not closely co-operating) programs." */ |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
75 |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
76 /* Open a pipe for output to a child process. |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
77 * The child's stdout goes to a file. |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
78 * |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
79 * write system read |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
80 * parent -> fd[0] -> STDIN_FILENO -> child |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
81 * |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
82 * Note: When writing to a child process, it is useful to ignore the SIGPIPE |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
83 * signal and the EPIPE error code. |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
84 */ |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
85 extern pid_t create_pipe_out (const char *progname, |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
86 const char *prog_path, char **prog_argv, |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
87 const char *prog_stdout, bool null_stderr, |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
88 bool slave_process, bool exit_on_error, |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
89 int fd[1]); |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
90 |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
91 /* Open a pipe for input from a child process. |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
92 * The child's stdin comes from a file. |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
93 * |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
94 * read system write |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
95 * parent <- fd[0] <- STDOUT_FILENO <- child |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
96 * |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
97 */ |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
98 extern pid_t create_pipe_in (const char *progname, |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
99 const char *prog_path, char **prog_argv, |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
100 const char *prog_stdin, bool null_stderr, |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
101 bool slave_process, bool exit_on_error, |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
102 int fd[1]); |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
103 |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
104 /* Open a bidirectional pipe. |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
105 * |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
106 * write system read |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
107 * parent -> fd[1] -> STDIN_FILENO -> child |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
108 * parent <- fd[0] <- STDOUT_FILENO <- child |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
109 * read system write |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
110 * |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
111 * Note: When writing to a child process, it is useful to ignore the SIGPIPE |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
112 * signal and the EPIPE error code. |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
113 * |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
114 * Note: The parent process must be careful to avoid deadlock. |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
115 * 1) If you write more than PIPE_MAX bytes or, more generally, if you write |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
116 * more bytes than the subprocess can handle at once, the subprocess |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
117 * may write its data and wait on you to read it, but you are currently |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
118 * busy writing. |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
119 * 2) When you don't know ahead of time how many bytes the subprocess |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
120 * will produce, the usual technique of calling read (fd, buf, BUFSIZ) |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
121 * with a fixed BUFSIZ will, on Linux 2.2.17 and on BSD systems, cause |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
122 * the read() call to block until *all* of the buffer has been filled. |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
123 * But the subprocess cannot produce more data until you gave it more |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
124 * input. But you are currently busy reading from it. |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
125 */ |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
126 extern pid_t create_pipe_bidi (const char *progname, |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
127 const char *prog_path, char **prog_argv, |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
128 bool null_stderr, |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
129 bool slave_process, bool exit_on_error, |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
130 int fd[2]); |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
131 |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
132 /* The name of the "always silent" device. */ |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
133 #if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
134 /* Native Woe32 API. */ |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
135 # define DEV_NULL "NUL" |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
136 #else |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
137 /* Unix API. */ |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
138 # define DEV_NULL "/dev/null" |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
139 #endif |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
140 |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
141 |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
142 #ifdef __cplusplus |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
143 } |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
144 #endif |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
145 |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
146 |
5be0c314f2f8
Rename module 'pipe' to 'spawn-pipe'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
147 #endif /* _SPAWN_PIPE_H */ |