diff options
| -rw-r--r-- | src/process.cpp | 19 | ||||
| -rw-r--r-- | src/process.h | 6 | 
2 files changed, 21 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 | ||
| diff --git a/src/process.h b/src/process.h index 665f1e0..3fcf1f2 100644 --- a/src/process.h +++ b/src/process.h | |||
| @@ -37,6 +37,12 @@ namespace Bu | |||
| 37 | Process( Flags eFlags, const char *sName, const char *argv, ...); | 37 | Process( Flags eFlags, const char *sName, const char *argv, ...); | 
| 38 | virtual ~Process(); | 38 | virtual ~Process(); | 
| 39 | 39 | ||
| 40 | /** | ||
| 41 | * Waits until the process exits. This blocks the caller until the | ||
| 42 | * child process terminates. | ||
| 43 | */ | ||
| 44 | void wait(); | ||
| 45 | |||
| 40 | virtual void close(); | 46 | virtual void close(); | 
| 41 | virtual size_t read( void *pBuf, size_t nBytes ); | 47 | virtual size_t read( void *pBuf, size_t nBytes ); | 
| 42 | virtual size_t readErr( void *pBuf, size_t nBytes ); | 48 | virtual size_t readErr( void *pBuf, size_t nBytes ); | 
