diff options
Diffstat (limited to '')
-rw-r--r-- | src/process.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/process.cpp b/src/process.cpp index e71b782..5781600 100644 --- a/src/process.cpp +++ b/src/process.cpp | |||
@@ -12,6 +12,7 @@ | |||
12 | #include <stdarg.h> | 12 | #include <stdarg.h> |
13 | #include <signal.h> | 13 | #include <signal.h> |
14 | #include <fcntl.h> | 14 | #include <fcntl.h> |
15 | #include <errno.h> | ||
15 | 16 | ||
16 | Bu::Process::Process( const char *sName, char *const argv[] ) | 17 | Bu::Process::Process( const char *sName, char *const argv[] ) |
17 | { | 18 | { |
@@ -69,6 +70,7 @@ void Bu::Process::gexec( const char *sName, char *const argv[] ) | |||
69 | dup2( iaStdOut[1], 1 ); | 70 | dup2( iaStdOut[1], 1 ); |
70 | // dup2( iaStdErr[1], 2 ); | 71 | // dup2( iaStdErr[1], 2 ); |
71 | execvp( sName, argv ); | 72 | execvp( sName, argv ); |
73 | throw Bu::ExceptionBase("Hey, execvp failed!"); | ||
72 | } | 74 | } |
73 | ::close( iaStdIn[0] ); | 75 | ::close( iaStdIn[0] ); |
74 | ::close( iaStdOut[1] ); | 76 | ::close( iaStdOut[1] ); |
@@ -81,6 +83,8 @@ void Bu::Process::close() | |||
81 | 83 | ||
82 | size_t Bu::Process::read( void *pBuf, size_t nBytes ) | 84 | size_t Bu::Process::read( void *pBuf, size_t nBytes ) |
83 | { | 85 | { |
86 | return TEMP_FAILURE_RETRY( ::read( iStdOut, pBuf, nBytes ) ); | ||
87 | /* | ||
84 | size_t iTotal = 0; | 88 | size_t iTotal = 0; |
85 | for(;;) | 89 | for(;;) |
86 | { | 90 | { |
@@ -91,6 +95,7 @@ size_t Bu::Process::read( void *pBuf, size_t nBytes ) | |||
91 | if( iTotal == nBytes ) | 95 | if( iTotal == nBytes ) |
92 | return iTotal; | 96 | return iTotal; |
93 | } | 97 | } |
98 | */ | ||
94 | /* | 99 | /* |
95 | size_t iTotal = 0; | 100 | size_t iTotal = 0; |
96 | fd_set rfs; | 101 | fd_set rfs; |
@@ -124,7 +129,7 @@ size_t Bu::Process::readErr( void *pBuf, size_t nBytes ) | |||
124 | 129 | ||
125 | size_t Bu::Process::write( const void *pBuf, size_t nBytes ) | 130 | size_t Bu::Process::write( const void *pBuf, size_t nBytes ) |
126 | { | 131 | { |
127 | return ::write( iStdIn, pBuf, nBytes ); | 132 | return TEMP_FAILURE_RETRY( ::write( iStdIn, pBuf, nBytes ) ); |
128 | } | 133 | } |
129 | 134 | ||
130 | long Bu::Process::tell() | 135 | long Bu::Process::tell() |
@@ -190,5 +195,9 @@ bool Bu::Process::isBlocking() | |||
190 | 195 | ||
191 | void Bu::Process::setBlocking( bool bBlocking ) | 196 | void Bu::Process::setBlocking( bool bBlocking ) |
192 | { | 197 | { |
198 | if( bBlocking ) | ||
199 | fcntl( iStdOut, F_SETFL, fcntl( iStdOut, F_GETFL, 0 )&(~O_NONBLOCK) ); | ||
200 | else | ||
201 | fcntl( iStdOut, F_SETFL, fcntl( iStdOut, F_GETFL, 0 )|O_NONBLOCK ); | ||
193 | } | 202 | } |
194 | 203 | ||