3 #ifndef WIBBLE_SYS_CHILDPROCESS_H 4 #define WIBBLE_SYS_CHILDPROCESS_H 26 #include <sys/types.h> 56 PROCESS_INFORMATION pi;
67 virtual int main() = 0;
88 ChildProcess() : _pid(-1), _stdin( 0 ), _stdout( 0 ), _stderr( 0 ) {}
105 void setupRedirects(
int* stdinfd = 0,
int* stdoutfd = 0,
int* stderrfd = 0);
128 int wait(
struct rusage* ru = 0);
131 void kill(
int signal);
void setupParent()
Definition: childprocess.cpp:216
int pipes[3][2]
Definition: childprocess.h:46
Fork a child process.
Definition: childprocess.h:42
void setExec(std::string command)
Instead of calling the main() function of this class, execute an external command.
Definition: childprocess.h:94
void waitForSuccess()
Definition: childprocess.cpp:287
ChildProcess()
Definition: childprocess.h:88
std::string m_command
Definition: childprocess.h:51
int * _stderr
Definition: childprocess.h:48
int wait(struct rusage *ru=0)
Wait for the child to finish, returning its exit status and optionally storing resource usage informa...
Definition: childprocess.cpp:270
pid_t forkAndRedirect(int *stdinfd=0, int *stdoutfd=0, int *stderrfd=0)
Definition: childprocess.h:107
bool m_doExec
Definition: childprocess.h:50
void kill(int signal)
Send the given signal to the process.
Definition: childprocess.cpp:310
void waitError()
Definition: childprocess.cpp:240
int m_status
Definition: childprocess.h:49
pid_t fork()
For a subprocess to run proc.
virtual void spawnChild()
On Windows, it's impossible to fork(), but if you were to fork+exec, it's not all lost...
Definition: childprocess.cpp:48
virtual ~ChildProcess()
Definition: childprocess.h:89
void setupChild()
Definition: childprocess.cpp:187
void setupRedirects(int *stdinfd=0, int *stdoutfd=0, int *stderrfd=0)
Definition: childprocess.cpp:145
pid_t _pid
Definition: childprocess.h:45
pid_t pid() const
Get the pid of the child process or (pid_t)-1 if no child is running.
Definition: childprocess.h:119
int * _stdin
Definition: childprocess.h:48
void setupPrefork()
Definition: childprocess.cpp:164
bool running()
Definition: childprocess.cpp:247
virtual int main()=0
Main function to be called in the child process after it has forked.
int * _stdout
Definition: childprocess.h:48