ucommon
Protected Member Functions | Protected Attributes | Friends
ucommon::shell::pipeio Class Reference

A class to control a process that is piped. More...

#include <shell.h>

Inheritance diagram for ucommon::shell::pipeio:
Inheritance graph
[legend]

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=((void *) 0))
 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

Detailed Description

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.

Author
David Sugar dyfet.nosp@m.@gnu.nosp@m.telep.nosp@m.hony.nosp@m..org

Definition at line 164 of file shell.h.

Member Function Documentation

int ucommon::shell::pipeio::cancel ( void  )
protected

Signal termination and wait for child process to exit.

When it does all piping is closed.

Returns
process exit code or -1 if error.
size_t ucommon::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.

Parameters
addressto store input.
sizeof input to read.
Returns
number of bytes actually read.
int ucommon::shell::pipeio::spawn ( char *  path,
char **  argv,
pmode_t  mode,
size_t  size = 512,
char **  env = ((void *) 0) 
)
protected

Spawn and attach child process I/O through piping.

Stderr is left attached to the console.

Parameters
pathof program to execute. If simple file, $PATH is used.
argvto pass to child process.
modeof pipe operation; rdonly, wronly, or rdwr.
sizeof atomic pipe buffer if setable.
envthat may optionally be given to the child process.
int ucommon::shell::pipeio::wait ( void  )
protected

Wait for child process to exit.

When it does, close all piping.

Returns
process exit code or -1 if error.
size_t ucommon::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.

Parameters
addressto write data from.
sizeof data to write.
Returns
number of bytes actually written.

The documentation for this class was generated from the following file: