diff options
Diffstat (limited to 'src/process.h')
-rw-r--r-- | src/process.h | 51 |
1 files changed, 48 insertions, 3 deletions
diff --git a/src/process.h b/src/process.h index e04bb59..843ead1 100644 --- a/src/process.h +++ b/src/process.h | |||
@@ -24,8 +24,16 @@ namespace Bu | |||
24 | class Process : public Bu::Stream | 24 | class Process : public Bu::Stream |
25 | { | 25 | { |
26 | public: | 26 | public: |
27 | Process( const char *sName, char *const argv[] ); | 27 | enum Flags |
28 | Process( const char *sName, const char *argv, ...); | 28 | { |
29 | StdOut = 0x01, | ||
30 | StdErr = 0x02, | ||
31 | Both = 0x03 | ||
32 | }; | ||
33 | |||
34 | public: | ||
35 | Process( Flags eFlags, const char *sName, char *const argv[] ); | ||
36 | Process( Flags eFlags, const char *sName, const char *argv, ...); | ||
29 | virtual ~Process(); | 37 | virtual ~Process(); |
30 | 38 | ||
31 | virtual void close(); | 39 | virtual void close(); |
@@ -53,6 +61,11 @@ namespace Bu | |||
53 | virtual bool isBlocking(); | 61 | virtual bool isBlocking(); |
54 | virtual void setBlocking( bool bBlocking=true ); | 62 | virtual void setBlocking( bool bBlocking=true ); |
55 | 63 | ||
64 | void select( bool &bStdOut, bool &bStdErr ); | ||
65 | |||
66 | bool isRunning(); | ||
67 | void ignoreStdErr(); | ||
68 | |||
56 | /** | 69 | /** |
57 | * Returns the pid of the child process, or zero if there is no | 70 | * Returns the pid of the child process, or zero if there is no |
58 | * currently running child. Note that a read operation must be | 71 | * currently running child. Note that a read operation must be |
@@ -60,13 +73,45 @@ namespace Bu | |||
60 | */ | 73 | */ |
61 | pid_t getPid(); | 74 | pid_t getPid(); |
62 | 75 | ||
76 | /** | ||
77 | * Returns true if the child exited normally (by calling exit or | ||
78 | * returning from main). | ||
79 | */ | ||
80 | bool childExited(); | ||
81 | |||
82 | /** | ||
83 | * Returns the 8 bit integer value returned from the child program if | ||
84 | * childExited returned true. | ||
85 | */ | ||
86 | int childExitStatus(); | ||
87 | |||
88 | /** | ||
89 | * Returns true if the child exited because of a signal. | ||
90 | */ | ||
91 | bool childSignaled(); | ||
92 | |||
93 | /** | ||
94 | * Returns the signal ID if the childSignaled return true. | ||
95 | */ | ||
96 | int childSignal(); | ||
97 | |||
98 | /** | ||
99 | * Returns true if the child left a core dump behind when it exited. | ||
100 | */ | ||
101 | bool childCoreDumped(); | ||
102 | |||
63 | private: | 103 | private: |
64 | int iStdIn; | 104 | int iStdIn; |
65 | int iStdOut; | 105 | int iStdOut; |
66 | int iStdErr; | 106 | int iStdErr; |
67 | pid_t iPid; | 107 | pid_t iPid; |
108 | int iProcStatus; | ||
109 | bool bBlocking; | ||
110 | bool bStdOutEos; | ||
111 | bool bStdErrEos; | ||
68 | 112 | ||
69 | void gexec( const char *sName, char *const argv[] ); | 113 | void gexec( Flags eFlags, const char *sName, char *const argv[] ); |
114 | void checkClose(); | ||
70 | }; | 115 | }; |
71 | } | 116 | } |
72 | 117 | ||