summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-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 )