process Class Reference

Abstraction for a child process. More...

#include <process.h>

Inheritance diagram for process:
Inheritance graph
[legend]
Collaboration diagram for process:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 process (const string &name="noname", bool withStdErr=false)
 process (const string &name, const value &v, bool withStdErr)
 process (bool nostart)
void init (const string &name, bool withStdErr)
virtual ~process (void)
void serialize (void)
bool running (void)
void kill (int sig)
void run (void)
bool waitforline (string &into, int ti, int maxsz=1024)
stringgets (void)
bool puts (const string &s)
void close (void)
bool printf (const char *,...)
stringread (size_t sz)
stringread (size_t sz, unsigned int ti)
bool eof (void)
void terminate (void)
virtual int main (void)
pid_t pid (void)
int retval (void)

Protected Attributes

pid_t _pid
bool _running
int _retval
string _name
file _inf
file _outf
file fin
file fout
file ferr
value data

Detailed Description

Abstraction for a child process.

Classes derived from this class can fork() off a process and communicate with its input and output channels.


Constructor & Destructor Documentation

process::process ( const string name = "noname",
bool  withStdErr = false 
) [inline]

Constructor.

Will spawn the actual process, so object creation should be followed by a call to process::run().

Parameters:
name Process title.
withStdErr If true, stderr will be intercepted.

References init().

Here is the call graph for this function:

process::process ( const string name,
const value v,
bool  withStdErr 
) [inline]

Constructor.

Will spawn the actual process, so object creation should be followed by a call to process::run().

Parameters:
name Process title.
v Process arguments.
withStdErr If true, stderr will be intercepted.

References data, and init().

Here is the call graph for this function:

process::process ( bool  nostart  )  [inline]

Constructor for an 'empty' process.

You need to call process::init() manually before you can call process::run().

virtual process::~process ( void   )  [inline, virtual]

Destructor.

Will kill the child process.

References kill(), and running().

Here is the call graph for this function:


Member Function Documentation

bool process::eof ( void   )  [inline]

End-of-file.

Returns:
Status, true if there's an EOF condition.

References _inf, and file::eof().

Here is the call graph for this function:

string* process::gets ( void   )  [inline]

Get a line of text from the process' output stream.

Returns:
New string object with the text line, minus its end-of-line markings.

References _inf, and file::gets().

Here is the call graph for this function:

void process::init ( const string name,
bool  withStdErr 
)

Init the process structure and perform the fork().

Parameters:
name The process title.
withStdErr The stderr flag.

References _inf, _name, _outf, _pid, _running, close(), ferr, fin, fout, lockbase::lockw(), file::openread(), file::openwrite(), stringrefdb::treelock, and lockbase::unlock().

Referenced by process(), and systemprocess::systemprocess().

Here is the call graph for this function:

void process::kill ( int  sig  ) 

Send a signal to the child process.

Parameters:
sig The signal to be sent.

References _pid, systemclass::procFunctions::kill(), systemclass::proc, and running().

Referenced by terminate(), and ~process().

Here is the call graph for this function:

int process::main ( void   )  [virtual]

Virtual main method.

Implements the background process.

Returns:
Process return-value.

Reimplemented in systemprocess.

References printf().

Referenced by run().

Here is the call graph for this function:

pid_t process::pid ( void   )  [inline]

Get child process-id.

Returns:
The pid, or 0 if the process isn't running.

References _pid, and running().

Here is the call graph for this function:

bool process::printf ( const char *  fmt,
  ... 
)

Send formatted data to the process input stream.

Returns:
Status, true if operation succeeded.

References string::printf_va(), and puts().

Referenced by main().

Here is the call graph for this function:

bool process::puts ( const string s  )  [inline]

Send data to the process input stream.

Parameters:
s The data to be sent.

References _outf, and file::puts().

Referenced by printf().

Here is the call graph for this function:

string* process::read ( size_t  sz  )  [inline]

Read a number of bytes from the process output.

Parameters:
sz The number of bytes to read.
Returns:
New string object with read data.

References _inf, and file::read().

Here is the call graph for this function:

int process::retval ( void   )  [inline]

Return value.

The process must be finished, use serialize() if necessary.

References _retval.

bool process::running ( void   ) 

Find out process running status.

Returns:
Status, true if the child process is running

References _pid, _retval, and _running.

Referenced by kill(), pid(), terminate(), and ~process().

void process::terminate ( void   )  [inline]

Kill child.

Will send a SIGTERM to the child process if it is still running.

References kill(), and running().

Here is the call graph for this function:


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

Generated on Sun Feb 28 10:36:14 2010 for GRACE by  doxygen 1.6.1