UCommon
|
Process pipe with I/O buffering. More...
#include <shell.h>
Public Member Functions | |
void | cancel (void) |
Terminate child process. | |
void | close (void) |
Close the i/o buffer. | |
iobuf (const char *path, char **argv, pmode_t mode, size_t size=512, char **env=NULL) | |
Construct an i/o buffer for a child process. | |
iobuf (size_t size=0) | |
Construct an i/o buffer. | |
void | open (const char *path, char **argv, pmode_t mode, size_t size=512, char **env=NULL) |
Open the i/o buffer attached to a child process. | |
~iobuf () | |
Destroy i/o buffer. | |
Protected Member Functions | |
virtual void | _clear (void) |
Method to clear low level i/o error. | |
virtual int | _err (void) const |
Method to get low level i/o error. | |
virtual size_t | _pull (char *address, size_t size) |
Method to pull buffer from physical i/o (read). | |
virtual size_t | _push (const char *address, size_t size) |
Method to push buffer into physical i/o (write). | |
Protected Attributes | |
int | ioerror |
Friends | |
class | shell |
Process pipe with I/O buffering.
This allows the creation and management of a shell pipe with buffered I/O support. This also offers a common class to manage stdio sessions generically in the child process.
shell::iobuf::iobuf | ( | size_t | size = 0 | ) |
Construct an i/o buffer.
If a non-zero size is specified, then the object is attached to the process's stdin & stdout. Otherwise an un-opened object is created.
shell::iobuf::iobuf | ( | const char * | path, |
char ** | argv, | ||
pmode_t | mode, | ||
size_t | size = 512 , |
||
char ** | env = NULL |
||
) |
Construct an i/o buffer for a child process.
This is used to create a child process directly when the object is made. It essentially is the same as the open() method.
path | of program to execute, if filename uses $PATH. |
argv | to pass to child process. |
mode | of pipe, rdonly, wronly, or rdwr. |
size | of buffering, and atomic pipe size if settable. |
env | that may be passed to child process. |
shell::iobuf::~iobuf | ( | ) |
Destroy i/o buffer.
This may cancel and block waiting for a child process to terminate.
virtual int shell::iobuf::_err | ( | void | ) | const [protected, virtual] |
Method to get low level i/o error.
Implements BufferProtocol.
virtual size_t shell::iobuf::_pull | ( | char * | address, |
size_t | size | ||
) | [protected, virtual] |
Method to pull buffer from physical i/o (read).
The address is passed to this virtual since it is hidden as private.
address | of buffer to pull data into. |
size | of buffer area being pulled.. |
Implements BufferProtocol.
virtual size_t shell::iobuf::_push | ( | const char * | address, |
size_t | size | ||
) | [protected, virtual] |
Method to push buffer into physical i/o (write).
The address is passed to this virtual since it is hidden as private.
address | of data to push. |
size | of data to push. |
Implements BufferProtocol.
void shell::iobuf::cancel | ( | void | ) |
Terminate child process.
This also waits for the child process to exit and then closes buffers.
Reimplemented from shell::pipeio.
void shell::iobuf::close | ( | void | ) |
Close the i/o buffer.
If attached to a child process it will wait for the child to exit.
void shell::iobuf::open | ( | const char * | path, |
char ** | argv, | ||
pmode_t | mode, | ||
size_t | size = 512 , |
||
char ** | env = NULL |
||
) |
Open the i/o buffer attached to a child process.
path | of program to execute, if filename uses $PATH. |
argv | to pass to child process. |
mode | of pipe, rdonly, wronly, or rdwr. |
size | of buffering, and atomic pipe size if settable. |
env | that may be passed to child process. |