Go forward to Backing Up.
Go backward to Stdiobuf.
Go up to Streambuf.
Reading/writing from/to a pipe
==============================
The "procbuf" class is a GNU extension. It is derived from
`streambuf'. A `procbuf' can be "closed" (in which case it does
nothing), or "open" (in which case it allows communicating through a
pipe with some other program).
- Constructor: procbuf::procbuf ()
Creates a `procbuf' in a "closed" state.
- Method: procbuf* procbuf::open (const char *COMMAND, int MODE)
Uses the shell (`/bin/sh') to run a program specified by COMMAND.
If MODE is `ios::in', standard output from the program is sent to
a pipe; you can read from the pipe by reading from the `procbuf'.
(This is similar to `popen(COMMAND, "r")'.)
If MODE is `ios::out', output written written to the `procbuf' is
written to a pipe; the program is set up to read its standard
input from (the other end of) the pipe. (This is similar to
`popen(COMMAND, "w")'.)
The `procbuf' must start out in the "closed" state. Returns
`*this' on success, and `NULL' on failure.
- Constructor: procbuf::procbuf (const char *COMMAND, int MODE)
Calls `procbuf::open (COMMAND, MODE)'.
- Method: procbuf* procbuf::close ()
Waits for the program to finish executing, and then cleans up the
resources used. Returns `*this' on success, and `NULL' on failure.
- Destructor: procbuf::~procbuf ()
Calls `procbuf::close'.