This class encapsulates threadsafe subprocess handling on the current platform. It provides support to spawn a child of the process, access its stdin, stdout and stderr file handle, test it's status and eventually wait for its termination.
The encapsulation is made so that the child process can be referenced to the thread that spawned it; if the father thread is cancelled, so the child process is.
|
Public Member Functions |
| OSProcessPthread () |
| ~OSProcessPthread () |
virtual bool | running () |
virtual bool | wait (const double seconds=-1.0) |
virtual bool | start (const std::string process, bool useShell=false, bool usePath=true) |
virtual bool | stop () |
virtual bool | getProcessValue (int &retvalue) const |
virtual file_size_t | getProcessId () const |
virtual int | write (const void *data, const int size, const double seconds=-1.0) |
virtual int | read (void *data, const int size, const double seconds=-1.0) |
virtual int | readStdErr (void *data, const int size, const double seconds=-1.0) |
virtual void | mergeStdErr () |
virtual void | detach () |
virtual void | sinkInput () |
virtual void | sinkOutput () |
virtual void | sinkError () |
virtual bool | closeRead () |
virtual bool | closeWrite () |
virtual bool | closeStdErr () |
virtual void | handleCleanup (int code, void *caller=0) |
Private Member Functions |
void | detachUnlocked () |
Static Private Member Functions |
int | parametrize (char *dese, const char *src) |
char ** | argvize (char *dest, int size) |
Private Attributes |
pthread_mutex_t | m_mutex |
pid_t | m_pid |
int | m_childIn |
int | m_childOut |
int | m_childErr |
bool | m_sinkIn |
bool | m_sinkOut |
bool | m_sinkErr |