diff options
-rw-r--r-- | src/process.cpp | 15 |
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 | ||
17 | Bu::Process::Process( const char *sName, char *const argv[] ) | 17 | Bu::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 | ||
22 | Bu::Process::Process( const char *sName, const char *argv, ...) | 23 | Bu::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 | ||
44 | Bu::Process::~Process() | 46 | Bu::Process::~Process() |
45 | { | 47 | { |
48 | close(); | ||
46 | } | 49 | } |
47 | 50 | ||
48 | void Bu::Process::gexec( const char *sName, char *const argv[] ) | 51 | void 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 | ||
80 | void Bu::Process::close() | 83 | void 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 | ||
84 | size_t Bu::Process::read( void *pBuf, size_t nBytes ) | 95 | size_t Bu::Process::read( void *pBuf, size_t nBytes ) |