aboutsummaryrefslogtreecommitdiff
path: root/src/process.cpp
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2009-07-31 16:43:16 +0000
committerMike Buland <eichlan@xagasoft.com>2009-07-31 16:43:16 +0000
commit6070f3cb3fe44f17114fd58792055e9c91bd3576 (patch)
tree317cee043edcb891839643dc67d8f3b96718bfbc /src/process.cpp
parent4b6a91106a0033dc289a9663632aee776af878f0 (diff)
downloadlibbu++-6070f3cb3fe44f17114fd58792055e9c91bd3576.tar.gz
libbu++-6070f3cb3fe44f17114fd58792055e9c91bd3576.tar.bz2
libbu++-6070f3cb3fe44f17114fd58792055e9c91bd3576.tar.xz
libbu++-6070f3cb3fe44f17114fd58792055e9c91bd3576.zip
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.
Diffstat (limited to '')
-rw-r--r--src/process.cpp15
1 files changed, 13 insertions, 2 deletions
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 @@
14#include <fcntl.h> 14#include <fcntl.h>
15#include <errno.h> 15#include <errno.h>
16 16
17Bu::Process::Process( const char *sName, char *const argv[] ) 17Bu::Process::Process( const char *sName, char *const argv[] ) :
18 iPid( 0 )
18{ 19{
19 gexec( sName, argv ); 20 gexec( sName, argv );
20} 21}
21 22
22Bu::Process::Process( const char *sName, const char *argv, ...) 23Bu::Process::Process( const char *sName, const char *argv, ...) :
24 iPid( 0 )
23{ 25{
24 int iCnt = 0; 26 int iCnt = 0;
25 va_list ap; 27 va_list ap;
@@ -43,6 +45,7 @@ Bu::Process::Process( const char *sName, const char *argv, ...)
43 45
44Bu::Process::~Process() 46Bu::Process::~Process()
45{ 47{
48 close();
46} 49}
47 50
48void Bu::Process::gexec( const char *sName, char *const argv[] ) 51void Bu::Process::gexec( const char *sName, char *const argv[] )
@@ -79,6 +82,14 @@ void Bu::Process::gexec( const char *sName, char *const argv[] )
79 82
80void Bu::Process::close() 83void Bu::Process::close()
81{ 84{
85 if( iPid )
86 {
87 ::close( iStdIn );
88 ::close( iStdOut );
89 int status;
90 waitpid( iPid, &status, 0 );
91 iPid = 0;
92 }
82} 93}
83 94
84size_t Bu::Process::read( void *pBuf, size_t nBytes ) 95size_t Bu::Process::read( void *pBuf, size_t nBytes )