Abstraction for a child process. More...
#include <process.h>


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) |
| string * | gets (void) |
| bool | puts (const string &s) |
| void | close (void) |
| bool | printf (const char *,...) |
| string * | read (size_t sz) |
| string * | read (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 |
Abstraction for a child process.
Classes derived from this class can fork() off a process and communicate with its input and output channels.
| 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().
| name | Process title. | |
| withStdErr | If true, stderr will be intercepted. |
References init().

Constructor.
Will spawn the actual process, so object creation should be followed by a call to process::run().
| name | Process title. | |
| v | Process arguments. | |
| withStdErr | If true, stderr will be intercepted. |

| 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] |
| bool process::eof | ( | void | ) | [inline] |
End-of-file.
References _inf, and file::eof().

| string* process::gets | ( | void | ) | [inline] |
Get a line of text from the process' output stream.
References _inf, and file::gets().

| void process::init | ( | const string & | name, | |
| bool | withStdErr | |||
| ) |
Init the process structure and perform the fork().
| 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().

| void process::kill | ( | int | sig | ) |
Send a signal to the child process.
| sig | The signal to be sent. |
References _pid, systemclass::procFunctions::kill(), systemclass::proc, and running().
Referenced by terminate(), and ~process().

| int process::main | ( | void | ) | [virtual] |
Virtual main method.
Implements the background process.
Reimplemented in systemprocess.
References printf().
Referenced by run().

| pid_t process::pid | ( | void | ) | [inline] |
| bool process::printf | ( | const char * | fmt, | |
| ... | ||||
| ) |
Send formatted data to the process input stream.
References string::printf_va(), and puts().
Referenced by main().

| bool process::puts | ( | const string & | s | ) | [inline] |
Send data to the process input stream.
| s | The data to be sent. |
References _outf, and file::puts().
Referenced by printf().

| string* process::read | ( | size_t | sz | ) | [inline] |
Read a number of bytes from the process output.
| sz | The number of bytes to read. |
References _inf, and file::read().

| int process::retval | ( | void | ) | [inline] |
| bool process::running | ( | void | ) |
Find out process running status.
References _pid, _retval, and _running.
Referenced by kill(), pid(), terminate(), and ~process().
| void process::terminate | ( | void | ) | [inline] |
1.6.1