Process 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/stderr and closes the program after use. More...

#include <Process.h>

Inheritance diagram for Process:

ExternalProgram ExternalDataSource

List of all members.

Public Member Functions

 Process (const std::string &commandline, bool use_pty=false, bool default_locale=false, bool pty_trans=true)
 Process (const char *const *argv, const Environment &environment, bool use_pty=false, bool default_locale=false, bool pty_trans=true)
 ~Process ()
bool kill (int sig)
bool kill ()
std::string readLine ()
std::string read ()
std::string readErrLine ()
std::string readErr ()
int closeAll ()
void readStdoutToBuffer ()
void readStderrToBuffer ()
bool anyLineInStdout ()
FILE * errorFile ()

Private Member Functions

 Process (const Process &)
Processoperator= (const Process &)
int create_stderr_pipes ()
std::string GetLineFromBuffer (std::string &buffer)
void BufferNewStdoutLines ()
bool IsAnyLineInBuffer (const std::string &buffer)

Private Attributes

std::string stdout_buffer
std::string stderr_buffer
FILE * stderr_output


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/stderr and closes the program after use.

Constructor & Destructor Documentation

Process::Process ( const Process  )  [private]

Process::Process ( const std::string &  commandline,
bool  use_pty = false,
bool  default_locale = false,
bool  pty_trans = true 
) [inline]

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
use_pty start the process in a terminal

Process::Process ( const char *const *  argv,
const Environment environment,
bool  use_pty = false,
bool  default_locale = false,
bool  pty_trans = true 
) [inline]

Start an external program by giving the arguments as an arry of char *pointers. If environment is provided, variables will be added to the childs environment, overwriting existing ones.

Process::~Process (  ) 


Member Function Documentation

bool Process::anyLineInStdout (  ) 

Read whether there are some buffered lines

References BufferNewStdoutLines(), IsAnyLineInBuffer(), and stdout_buffer.

void Process::BufferNewStdoutLines (  )  [private]

int Process::closeAll (  ) 

Close all input/output filedescriptors

References ExternalProgram::close(), and stderr_output.

int Process::create_stderr_pipes (  )  [private]

References stderr_output, and UnblockFD().

FILE * Process::errorFile (  ) 

Return the stderror stream

References stderr_output.

Referenced by main().

std::string Process::GetLineFromBuffer ( std::string &  buffer  )  [private]

Referenced by readErrLine(), and readLine().

bool Process::IsAnyLineInBuffer ( const std::string &  buffer  )  [private]

Referenced by anyLineInStdout().

bool Process::kill (  ) 

Send SIGKILL

Reimplemented from ExternalProgram.

Referenced by kill(), and ~Process().

bool Process::kill ( int  sig  ) 

Send a signal

References ExternalProgram::getpid(), and kill().

Process& Process::operator= ( const Process  )  [private]

std::string Process::read (  ) 

Read characters from stdout (not line oriented)

References readStdoutToBuffer(), and stdout_buffer.

Referenced by main(), and readStdoutToBuffer().

std::string Process::readErr (  ) 

Read characters from stderr (not line oriented)

References readStderrToBuffer(), and stderr_buffer.

Referenced by main().

std::string Process::readErrLine (  ) 

Read a line from stderr

References GetLineFromBuffer(), readStderrToBuffer(), and stderr_buffer.

std::string Process::readLine (  ) 

Read a line from stdout

References BufferNewStdoutLines(), GetLineFromBuffer(), and stdout_buffer.

void Process::readStderrToBuffer (  ) 

Read stderr to the internal buffer (can unblock the process)

References b_size(), ERR, stderr_buffer, and stderr_output.

Referenced by readErr(), and readErrLine().

void Process::readStdoutToBuffer (  ) 

Read stdout to the internal buffer (can unblock the process)

References b_size(), read(), ExternalDataSource::receive(), and stdout_buffer.

Referenced by read().


Member Data Documentation

std::string Process::stderr_buffer [private]

FILE* Process::stderr_output [private]

std::string Process::stdout_buffer [private]


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

Generated on a sunny day for yast2-core by doxygen 1.5.9