00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef TJPROCESS_H
00019 #define TJPROCESS_H
00020
00021 #include <tjutils/tjstring.h>
00022 #include <tjutils/tjarray.h>
00023
00029
00030
00031
00032 class ProcessComponent {
00033 public:
00034 static const char* get_compName();
00035 };
00036
00038
00039
00043 class Process {
00044
00045 public:
00046
00050 Process() {reset();}
00051
00059 bool start(const STD_string& cmdline, bool block_till_finished=false, bool log_std_streams=true);
00060
00066 bool finished(int& proc_return_value, STD_string& stdout_result, STD_string& stderr_result, bool block_till_finished=false);
00067
00073 bool finished(int& proc_return_value, bool block_till_finished=false);
00074
00078 bool kill(const svector& extra_kill=svector());
00079
00084 static int system(const STD_string& cmdline, STD_string& stdout_result, STD_string& stderr_result);
00085
00086
00087
00088 bool operator == (const Process& op) const {return pid==op.pid;}
00089 bool operator < (const Process& op) const {return pid!=op.pid;}
00090 bool operator != (const Process& op) const {return !(*this==op);}
00091
00092 private:
00093
00094 static bool read_pipe(int fd, STD_string& result);
00095 void reset() {pid=0; stdout_child=-1; stderr_child=-1;}
00096
00097 int pid;
00098 int stdout_child;
00099 int stderr_child;
00100 };
00101
00102
00103
00106 #endif