golib
0.5
|
Process interface for Unix platforms (so far). More...
#include <goprocess.h>
Public Member Functions | |
void | setInput (int filedesc) |
void | setOutput (int filedesc) |
int | run (const char *filename, const char *arg) |
Calls a program by filename. More... | |
int | run (const char *filename, char *const argv[]) |
Runs a program by filename. More... | |
int | run (const char *filename, const goFixedArray< goString > &argv) |
Runs a program by filename. More... | |
void | wait () |
Waits until the child returns. More... | |
void | kill () |
Kills the child using SIGKILL. More... | |
void | suspend () |
Suspends the child process. More... | |
void | resume () |
Resumes the suspended child process. | |
![]() | |
goObjectBase () | |
Constructor. | |
virtual | ~goObjectBase () |
Destructor. More... | |
const char * | getClassName () const |
Returns the class name. More... | |
int | getClassID () const |
virtual goSize_t | memoryUsage () const |
Returns the size of this object or some measure of its memory consumption. More... | |
void | setObjectName (const char *name) |
Set name string for an object. More... | |
void | setObjectName (const goString &name) |
Set name string for an object. More... | |
const goString & | getObjectName () const |
Get the object name. More... | |
virtual bool | writeObjectFile (FILE *) const |
Write object to a file. More... | |
virtual bool | readObjectFile (FILE *) |
Read object from a file. More... | |
void | connectObject (goObjectBase *object) |
Connects an object to this object. More... | |
void | disconnectObject (const goObjectBase *object) |
Disconnects an object from this object. | |
virtual bool | callObjectMethod (int methodID, goObjectMethodParameters *param=NULL) |
Call an object method by identifier. More... | |
virtual bool | queueObjectMethod (int methodID, goObjectMethodParameters *param=NULL, bool blocking=false) |
Enqueue a method call to an internal list of methods. More... | |
bool | callQueuedMethods () |
Call all queued methods. More... | |
Protected Member Functions | |
void | redirectIO () |
void | deleteTemp () |
![]() | |
void | setClassID (int id) |
Sets the class name. | |
void | printClassMessage (const char *msg) |
Sets the class name. More... | |
void | printClassMessage (goString &msg) |
Prints an informational message to the calling console. More... | |
void | sendObjectMessage (int messageID, void *data=NULL) |
Sends a message to all connected objects. | |
void | sendObjectMessage (goObjectBase *object, int messageID, void *data=NULL) |
Sends a message to a specific object. | |
virtual void | receiveObjectMessage (const goObjectMessage &message) |
Receive a message. More... | |
Protected Attributes | |
bool | running |
int | pid |
int | inputFD |
int | outputFD |
Process interface for Unix platforms (so far).
The OS has to provide the necessary exec* functions and a fork() function. I recommend using the run ( ..., goArray<goString* >& argv) member for starting the child process. In this case, only the real parameters have to be provided by the user. When using the run(const char* filename, char *const argv[]) member, the user has to provide argv[0] as the programname (as usual) and the array has to be ended by a NULL pointer.
void goProcess::kill | ( | ) |
Kills the child using SIGKILL.
Ends the child process by sending a SIGKILL signal.
int goProcess::run | ( | const char * | filename, |
char *const | argv[] | ||
) |
Runs a program by filename.
filename | Filename of the program. |
argv | Array of arguments for the program. |
int goProcess::run | ( | const char * | filename, |
const char * | arg | ||
) |
Calls a program by filename.
filename | Filename of the program. |
arg | Argument string for the program. |
int goProcess::run | ( | const char * | filename_, |
const goFixedArray< goString > & | argv_ | ||
) |
Runs a program by filename.
filename | Filename of the program. |
argv | goArray of string pointers to the arguments. |
void goProcess::suspend | ( | ) |
Suspends the child process.
Resume it with the resume() method.
void goProcess::wait | ( | ) |
Waits until the child returns.
Waits for the process to return.