#include <wvpipe.h>
Inheritance diagram for WvPipe:
Public Member Functions | |
WvPipe (const char *program, const char *const *argv, bool writable, bool readable, bool catch_stderr, int stdin_fd=0, int stdout_fd=1, int stderr_fd=2) | |
WvPipe (const char *program, const char *const *argv, bool writable, bool readable, bool catch_stderr, WvStream *stdin_str, WvStream *stdout_str=NULL, WvStream *stderr_str=NULL) | |
WvPipe (const char *program, const char **argv, bool writable, bool readable, bool catch_stderr, WvSplitStream *stdio_str) | |
virtual | ~WvPipe () |
void | kill (int signum) |
int | finish () |
bool | child_exited () |
bool | child_killed () const |
int | exit_status () const |
int | getpid () const |
WvPipe (const char *program, const char *const *argv, bool writable, bool readable, bool catch_stderr, int stdin_fd=0, int stdout_fd=1, int stderr_fd=2) | |
WvPipe (const char *program, const char *const *argv, bool writable, bool readable, bool catch_stderr, WvStream *stdin_str, WvStream *stdout_str=NULL, WvStream *stderr_str=NULL) | |
WvPipe (const char *program, const char **argv, bool writable, bool readable, bool catch_stderr, WvSplitStream *stdio_str) | |
virtual | ~WvPipe () |
void | kill (int signum) |
int | finish () |
bool | child_exited () |
bool | child_killed () const |
int | exit_status () const |
int | getpid () const |
Protected Member Functions | |
void | setup (const char *program, const char *const *argv, bool writable, bool readable, bool catch_stderr, int stdin_fd, int stdout_fd, int stderr_fd) |
void | setup (const char *program, const char *const *argv, bool writable, bool readable, bool catch_stderr, int stdin_fd, int stdout_fd, int stderr_fd) |
Private Attributes | |
pid_t | pid |
int | estatus |
Unlike pipes created with the popen() system call, you can capture both stdin and stdout for the given process. This is because we actually use the socketpair() call instead. If you try this, however, you must be very careful to always use the select() call before reading from the stream. (Think what would happen if both ends of the pipe do a read() simultaneously!)
Note that we do not go as far as actually using a pty. That means programs which deliberately open /dev/tty will not be redirected.
When the WvPipe is destroyed, it makes sure that the child process is killed. Since it tries to do it politely (SIGTERM, wait up to 2 seconds, SIGKILL) it can take up to 2 seconds to destroy a WvPipe.
Definition at line 31 of file include/wvpipe.h.
|
default pipe constructor; if you just want to use a pipe, use this. For each of stdin, stdout, and stderr of the child process, it can do one of three things:
Definition at line 24 of file wvpipe.cc. References setup(). |
|
This constructor does much the same thing as the previous one, except that std*_str are WvStreams instead. The target process accesses the 'fd' member of the stream (NOT using the WvStream read() and write() functions). Again, we only redirect to the given WvStreams if the corresponding bool is false; otherwise, we redirect to the pipe. It is okay for the same WvStream to occur more than once. Also, you must naturally make sure that the stream doesn't disappear before WvPipe does! Definition at line 33 of file wvpipe.cc. References WvStream::getrfd(), WvStream::getwfd(), and setup(). |
|
This constructor is the same again, except that it uses the features of the WvSplitStream class to get all its fds from one place. Definition at line 49 of file wvpipe.cc. References WvSplitStream::getrfd(), WvSplitStream::getwfd(), and setup(). |
|
kill the child process and close the stream. Definition at line 217 of file wvpipe.cc. References WvStream::close(), kill(), and pid. |
|
default pipe constructor; if you just want to use a pipe, use this. For each of stdin, stdout, and stderr of the child process, it can do one of three things:
|
|
This constructor does much the same thing as the previous one, except that std*_str are WvStreams instead. The target process accesses the 'fd' member of the stream (NOT using the WvStream read() and write() functions). Again, we only redirect to the given WvStreams if the corresponding bool is false; otherwise, we redirect to the pipe. It is okay for the same WvStream to occur more than once. Also, you must naturally make sure that the stream doesn't disappear before WvPipe does! |
|
This constructor is the same again, except that it uses the features of the WvSplitStream class to get all its fds from one place. |
|
kill the child process and close the stream. |
|
returns true if child is dead. |
|
returns true if child is dead. Definition at line 177 of file wvpipe.cc. Referenced by finish(). |
|
returns true if child is dead because of a signal. |
|
returns true if child is dead because of a signal. Definition at line 195 of file wvpipe.cc. References estatus. Referenced by exit_status(). |
|
returns the exit status: if child_killed()==true, the signal that killed the child. if child_killed()==false, the return code of the program. |
|
returns the exit status: if child_killed()==true, the signal that killed the child. if child_killed()==false, the return code of the program. Definition at line 205 of file wvpipe.cc. References child_killed(), and estatus. Referenced by finish(). |
|
wait for child to die. Returns exit_status() |
|
wait for child to die. Returns exit_status() Definition at line 165 of file wvpipe.cc. References child_exited(), and exit_status(). |
|
Definition at line 113 of file streams/wvpipe.h. |
|
Definition at line 113 of file include/wvpipe.h. |
|
send the child a signal (signal names are defined in signal.h) |
|
send the child a signal (signal names are defined in signal.h) Definition at line 157 of file wvpipe.cc. References pid. Referenced by ~WvPipe(). |
|
|
|
Definition at line 64 of file wvpipe.cc. References WvStream::errnum, estatus, pid, and WvStream::rwfd. Referenced by WvPipe(). |
|
Definition at line 34 of file streams/wvpipe.h. Referenced by child_exited(), child_killed(), exit_status(), and setup(). |
|
Definition at line 33 of file streams/wvpipe.h. Referenced by child_exited(), kill(), setup(), and ~WvPipe(). |