f78
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).
procbuf::procbuf () Constructor
Creates a procbuf in a closed state.
procbuf* procbuf::open (const char * command, int mode) Method
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 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 7d6 in the closed state. Returns *this on success, and NULL on failure.
procbuf::procbuf (const char * command, int mode) Constructor
Calls procbuf::open(command, mode).
procbuf* procbuf::close () Method
Waits for the program to finish executing, and then cleans up the resources used. Returns *this on success, and NULL on failure.
procbuf::~procbuf () Destructor
Calls procbuf::close.