diff options
author | Mike Buland <eichlan@xagasoft.com> | 2010-05-20 06:32:38 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2010-05-20 06:32:38 +0000 |
commit | da38bfc4ed4d6714a5d9f1b42e002fe8221ae268 (patch) | |
tree | 986f59307b3849e97d9be90d370fd57a393a3296 /src/process.cpp | |
parent | 8b30bc900f17659d14aeb344e2b4d13d09d334ea (diff) | |
download | libbu++-da38bfc4ed4d6714a5d9f1b42e002fe8221ae268.tar.gz libbu++-da38bfc4ed4d6714a5d9f1b42e002fe8221ae268.tar.bz2 libbu++-da38bfc4ed4d6714a5d9f1b42e002fe8221ae268.tar.xz libbu++-da38bfc4ed4d6714a5d9f1b42e002fe8221ae268.zip |
Made process easier to use, when you ask it if the process has ended, it
actually checks. novel, eh?
Diffstat (limited to 'src/process.cpp')
-rw-r--r-- | src/process.cpp | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/src/process.cpp b/src/process.cpp index da38e64..7cb5983 100644 --- a/src/process.cpp +++ b/src/process.cpp | |||
@@ -66,6 +66,11 @@ Bu::Process::~Process() | |||
66 | close(); | 66 | close(); |
67 | } | 67 | } |
68 | 68 | ||
69 | void Bu::Process::wait() | ||
70 | { | ||
71 | close(); | ||
72 | } | ||
73 | |||
69 | void Bu::Process::gexec( Flags eFlags, const char *sName, char *const argv[] ) | 74 | void Bu::Process::gexec( Flags eFlags, const char *sName, char *const argv[] ) |
70 | { | 75 | { |
71 | int iaStdIn[2]; | 76 | int iaStdIn[2]; |
@@ -258,13 +263,17 @@ void Bu::Process::setBlocking( bool bBlocking ) | |||
258 | { | 263 | { |
259 | if( bBlocking ) | 264 | if( bBlocking ) |
260 | { | 265 | { |
261 | fcntl( iStdOut, F_SETFL, fcntl( iStdOut, F_GETFL, 0 )&(~O_NONBLOCK) ); | 266 | if( !bStdOutEos ) |
262 | fcntl( iStdErr, F_SETFL, fcntl( iStdErr, F_GETFL, 0 )&(~O_NONBLOCK) ); | 267 | fcntl( iStdOut, F_SETFL, fcntl(iStdOut,F_GETFL,0 )&(~O_NONBLOCK) ); |
268 | if( !bStdErrEos ) | ||
269 | fcntl( iStdErr, F_SETFL, fcntl(iStdErr,F_GETFL,0 )&(~O_NONBLOCK) ); | ||
263 | } | 270 | } |
264 | else | 271 | else |
265 | { | 272 | { |
266 | fcntl( iStdOut, F_SETFL, fcntl( iStdOut, F_GETFL, 0 )|O_NONBLOCK ); | 273 | if( !bStdOutEos ) |
267 | fcntl( iStdErr, F_SETFL, fcntl( iStdErr, F_GETFL, 0 )|O_NONBLOCK ); | 274 | fcntl( iStdOut, F_SETFL, fcntl( iStdOut, F_GETFL, 0 )|O_NONBLOCK ); |
275 | if( !bStdErrEos ) | ||
276 | fcntl( iStdErr, F_SETFL, fcntl( iStdErr, F_GETFL, 0 )|O_NONBLOCK ); | ||
268 | } | 277 | } |
269 | this->bBlocking = bBlocking; | 278 | this->bBlocking = bBlocking; |
270 | } | 279 | } |
@@ -293,6 +302,8 @@ void Bu::Process::select( bool &bStdOut, bool &bStdErr ) | |||
293 | 302 | ||
294 | bool Bu::Process::isRunning() | 303 | bool Bu::Process::isRunning() |
295 | { | 304 | { |
305 | if( waitpid( iPid, NULL, WNOHANG ) == iPid ) | ||
306 | close(); | ||
296 | return iPid != 0; | 307 | return iPid != 0; |
297 | } | 308 | } |
298 | 309 | ||