Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members

ExternalProgram Class Reference

Execute a program and give access to its io An object of this class encapsulates the execution of an external program. It starts the program using fork and some exec.. call, gives you access to the program's stdio and closes the program after use. More...

#include <ExternalProgram.h>

Inheritance diagram for ExternalProgram:

ExternalDataSource List of all members.

Public Types

enum  Stderr_Disposition { Normal_Stderr, Discard_Stderr, Stderr_To_Stdout, Stderr_To_FileDesc }

Public Member Functions

 ExternalProgram (std::string commandline, Stderr_Disposition stderr_disp=Normal_Stderr, bool use_pty=false, int stderr_fd=-1, bool default_locale=false, const Pathname &root="")
 ExternalProgram (const char *const *argv, Stderr_Disposition stderr_disp=Normal_Stderr, bool use_pty=false, int stderr_fd=-1, bool default_locale=false, const Pathname &root="")
 ExternalProgram (const char *binpath, const char *const *argv_1, bool use_pty=false)
 ~ExternalProgram ()
int close ()
bool kill ()
bool running ()
pid_t getpid ()

Protected Member Functions

int checkStatus (int)

Private Member Functions

void start_program (const char *const *argv, Stderr_Disposition stderr_disp=Normal_Stderr, int stderr_fd=-1, bool default_locale=false, const char *root=NULL)

Private Attributes

bool use_pty
pid_t pid
int _exitStatus

Detailed Description

Execute a program and give access to its io An object of this class encapsulates the execution of an external program. It starts the program using fork and some exec.. call, gives you access to the program's stdio and closes the program after use.


Member Enumeration Documentation

enum ExternalProgram::Stderr_Disposition
 

Define symbols for different policies on the handling of stderr

Enumeration values:
Normal_Stderr 
Discard_Stderr 
Stderr_To_Stdout 
Stderr_To_FileDesc 


Constructor & Destructor Documentation

ExternalProgram::ExternalProgram std::string  commandline,
Stderr_Disposition  stderr_disp = Normal_Stderr,
bool  use_pty = false,
int  stderr_fd = -1,
bool  default_locale = false,
const Pathname root = ""
 

Start the external program by using the shell /bin/sh with the option -c. You can use io direction symbols < and >.

Parameters:
commandline a shell commandline that is appended to /bin/sh -c.
default_locale whether to set LC_ALL=C before starting
root directory to chroot into, / or empty to not chroot

ExternalProgram::ExternalProgram const char *const *  argv,
Stderr_Disposition  stderr_disp = Normal_Stderr,
bool  use_pty = false,
int  stderr_fd = -1,
bool  default_locale = false,
const Pathname root = ""
 

Start an external program by giving the arguments as an arry of char *pointers.

ExternalProgram::ExternalProgram const char *  binpath,
const char *const *  argv_1,
bool  use_pty = false
 

ExternalProgram::~ExternalProgram  ) 
 


Member Function Documentation

int ExternalProgram::checkStatus int   )  [protected]
 

int ExternalProgram::close  )  [virtual]
 

Close the input and output streams.

Reimplemented from ExternalDataSource.

pid_t ExternalProgram::getpid  )  [inline]
 

return pid

bool ExternalProgram::kill  ) 
 

Kill the program

bool ExternalProgram::running  ) 
 

Return whether program is running

void ExternalProgram::start_program const char *const *  argv,
Stderr_Disposition  stderr_disp = Normal_Stderr,
int  stderr_fd = -1,
bool  default_locale = false,
const char *  root = NULL
[private]
 


Member Data Documentation

int ExternalProgram::_exitStatus [private]
 

pid_t ExternalProgram::pid [private]
 

bool ExternalProgram::use_pty [private]
 

Set to true, if a pair of ttys is used for communication instead of a pair of pipes.


The documentation for this class was generated from the following files:
Generated on Thu Feb 23 23:56:10 2006 for liby2util by doxygen 1.3.6