
An exception-safe wrapper around a pipe-fork-exec sequence. More...
#include <rutz/pipe.h>

| Public Member Functions | |
| bidir_pipe () | |
| Default construct; you MUST call init() before using any of the streams! | |
| bidir_pipe (char *const *argv) | |
| Set up a pipe to a child process with the given argv array. | |
| bidir_pipe (const char *argv0,...) | |
| Set up a pipe to a child process with the given list of args. | |
| ~bidir_pipe () throw () | |
| Destructor cleans up child process and the pipe's file descriptors. | |
| void | block_child_sigint () | 
| Request that SIGINT be ignored in the child process. | |
| void | init (char *const *argv) | 
| Core code for starting the child process. | |
| void | init (const char *argv0,...) | 
| Core code for starting the child process. | |
| std::iostream & | in_stream () throw () | 
| Get the stream that is receiving input from the child process. | |
| std::iostream & | out_stream () throw () | 
| Get the stream that is sending output to the child process. | |
| void | close_in () | 
| Close the underlying input stream file descriptor. | |
| void | close_out () | 
| Close the underlying output stream file descriptor. | |
| int | exit_status () throw () | 
| Wait for child process to complete, return 0 if all is OK, -1 if error. | |
An exception-safe wrapper around a pipe-fork-exec sequence.
Definition at line 170 of file pipe.h.
| rutz::bidir_pipe::bidir_pipe | ( | ) | 
| rutz::bidir_pipe::bidir_pipe | ( | char *const * | argv | ) | 
| rutz::bidir_pipe::bidir_pipe | ( | const char * | argv0, | |
| ... | ||||
| ) | 
Set up a pipe to a child process with the given list of args.
BE SURE the variable-length argument list is NULL-terminated!
A private copy will be made of all the arguments, so it is safe to pass const strings here (such as the result of str.c_str() for a std::string object).
Definition at line 308 of file pipe.cc.
References init().
| rutz::bidir_pipe::~bidir_pipe | ( | ) | throw () | 
Destructor cleans up child process and the pipe's file descriptors.
Definition at line 327 of file pipe.cc.
References close_in(), and close_out().
| void rutz::bidir_pipe::block_child_sigint | ( | ) | 
Request that SIGINT be ignored in the child process.
You must request this BEFORE calling init(); so the proper sequence is:
rutz::bidir_pipe prog; prog.block_child_signals(); prog.init("progname", "arg1", "arg2", NULL);
This functionality is useful if the parent process is already handling SIGINT specially; if you don't block SIGINT in the child process, then when the user presses Ctrl-C, the following happens: (1) the main parent handles the SIGINT, as desired, but (2) the child process also receives a SIGINT, thus it dies, and (3) the parent process then gets a SIGPIPE and dies itself without getting a chance for a clean exit.
| void rutz::bidir_pipe::close_in | ( | ) | 
Close the underlying input stream file descriptor.
Definition at line 425 of file pipe.cc.
References rutz::stdiostream::close().
Referenced by ~bidir_pipe().
| void rutz::bidir_pipe::close_out | ( | ) | 
Close the underlying output stream file descriptor.
Definition at line 436 of file pipe.cc.
References rutz::stdiostream::close().
Referenced by UcbMpegEncoder::close(), and ~bidir_pipe().
| int rutz::bidir_pipe::exit_status | ( | ) | throw () | 
Wait for child process to complete, return 0 if all is OK, -1 if error.
Definition at line 447 of file pipe.cc.
References rutz::child_process::wait().
Referenced by UcbMpegEncoder::close().
| std::iostream & rutz::bidir_pipe::in_stream | ( | ) | throw () | 
| void rutz::bidir_pipe::init | ( | const char * | argv0, | |
| ... | ||||
| ) | 
| void rutz::bidir_pipe::init | ( | char *const * | argv | ) | 
Core code for starting the child process.
NOTE the argv array must be NULL-terminated!
Definition at line 341 of file pipe.cc.
References in, rutz::child_process::in_parent(), and SRC_POS.
Referenced by bidir_pipe(), and init().
| std::iostream & rutz::bidir_pipe::out_stream | ( | ) | throw () | 
 1.6.3
 1.6.3