Table of Contents
The
function a process by creating a pipe, forking, and invoking the shell.
Since a pipe is by definition unidirectional, the argument may specify
only reading or writing, not both; the resulting stream is correspondingly
read-only or write-only. The argument is a pointer to a null-terminated string
containing a shell command line. This command is passed to using the flag;
interpretation, if any, is performed by the shell. The argument is a pointer
to a null-terminated string which must be either for reading or for writing.
The return value from is a normal standard stream in all respects save
that it must be closed with rather than Writing to such a stream writes
to the standard input of the command; the command’s standard output is the
same as that of the process that called unless this is altered by the
command itself. Conversely, reading from a stream reads the command’s standard
output, and the command’s standard input is the same as that of the process
that called Note that output streams are fully buffered by default.
The function waits for the associated process to terminate and returns
the exit status of the command as returned by
The function
returns if the or calls fail, or if it cannot allocate memory. The
function returns -1 if is not associated with a command, if already
or if returns an error.
The function does not reliably set
Since the standard input of a command opened for reading
shares its seek offset with the process that called if the original process
has done a buffered read, the command’s input position may not be as expected.
Similarly, the output from a command opened for writing may become intermingled
with that of the original process. The latter can be avoided by calling
before Failure to execute the shell is indistinguishable from the shell’s
failure to execute command, or an immediate exit of the command. The only
hint is an exit status of 127. The argument always calls never calls
A and a function appeared in
Table of Contents