From 6070f3cb3fe44f17114fd58792055e9c91bd3576 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Fri, 31 Jul 2009 16:43:16 +0000 Subject: Fixed Bu::Process' close function, it wasn't closing, now it actually closes the pipes and waits for the child process like it should. It doesn't force the child to close right now, I'm not sure it should, we'll figure that out later. --- src/process.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'src/process.cpp') diff --git a/src/process.cpp b/src/process.cpp index f04d9fb..ff40f73 100644 --- a/src/process.cpp +++ b/src/process.cpp @@ -14,12 +14,14 @@ #include #include -Bu::Process::Process( const char *sName, char *const argv[] ) +Bu::Process::Process( const char *sName, char *const argv[] ) : + iPid( 0 ) { gexec( sName, argv ); } -Bu::Process::Process( const char *sName, const char *argv, ...) +Bu::Process::Process( const char *sName, const char *argv, ...) : + iPid( 0 ) { int iCnt = 0; va_list ap; @@ -43,6 +45,7 @@ Bu::Process::Process( const char *sName, const char *argv, ...) Bu::Process::~Process() { + close(); } void Bu::Process::gexec( const char *sName, char *const argv[] ) @@ -79,6 +82,14 @@ void Bu::Process::gexec( const char *sName, char *const argv[] ) void Bu::Process::close() { + if( iPid ) + { + ::close( iStdIn ); + ::close( iStdOut ); + int status; + waitpid( iPid, &status, 0 ); + iPid = 0; + } } size_t Bu::Process::read( void *pBuf, size_t nBytes ) -- cgit v1.2.3