A class to control a process that is piped. More...
#include <shell.h>
Protected Member Functions | |
int | cancel (void) |
Signal termination and wait for child process to exit. | |
pipeio () | |
Construct an empty initialized pipe for use. | |
size_t | read (void *address, size_t size) |
Read input from child process. | |
int | spawn (char *path, char **argv, pmode_t mode, size_t size=512, char **env=NULL) |
Spawn and attach child process I/O through piping. | |
int | wait (void) |
Wait for child process to exit. | |
size_t | write (void *address, size_t size) |
Write to the child process. | |
Protected Attributes | |
fd_t | input |
fd_t | output |
int | perror |
pid_t | pid |
int | presult |
Friends | |
class | shell |
A class to control a process that is piped.
This holds the active file descriptors for the pipe as well as the process id. Basic I/O methods are provided to send and receive data with the piped child process. This may be used by itself with various shell methods as a pipe_t, or to construct piped objects such as iobuf.
Definition at line 141 of file shell.h.
int ucc::shell::pipeio::cancel | ( | void | ) | [protected] |
Signal termination and wait for child process to exit.
When it does all piping is closed.
Reimplemented in ucc::shell::iobuf.
size_t ucc::shell::pipeio::read | ( | void * | address, | |
size_t | size | |||
) | [protected] |
Read input from child process.
If there is an error, the result is 0 and perror holds the error code. If an error already happened no further data will be read.
address | to store input. | |
size | of input to read. |
int ucc::shell::pipeio::spawn | ( | char * | path, | |
char ** | argv, | |||
pmode_t | mode, | |||
size_t | size = 512 , |
|||
char ** | env = NULL | |||
) | [protected] |
Spawn and attach child process I/O through piping.
Stderr is left attached to the console.
path | of program to execute. If simple file, $PATH is used. | |
argv | to pass to child process. | |
mode | of pipe operation; rdonly, wronly, or rdwr. | |
size | of atomic pipe buffer if setable. | |
env | that may optionally be given to the child process. |
int ucc::shell::pipeio::wait | ( | void | ) | [protected] |
Wait for child process to exit.
When it does, close all piping.
size_t ucc::shell::pipeio::write | ( | void * | address, | |
size_t | size | |||
) | [protected] |
Write to the child process.
If there is an error, the result is 0 and perror holds the error code. If an error already happened no further data will be written.
address | to write data from. | |
size | of data to write. |