aboutsummaryrefslogtreecommitdiff
path: root/src/process.cpp
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2009-12-10 22:35:51 +0000
committerMike Buland <eichlan@xagasoft.com>2009-12-10 22:35:51 +0000
commite35e62a080ac636f5820b2f88f75a1383f14d713 (patch)
tree73af59f762670c0a0dff82b6f707aff63b9ba197 /src/process.cpp
parent3cef0a39bc70308fd5a1fb3783c5f4ca716aca80 (diff)
downloadlibbu++-e35e62a080ac636f5820b2f88f75a1383f14d713.tar.gz
libbu++-e35e62a080ac636f5820b2f88f75a1383f14d713.tar.bz2
libbu++-e35e62a080ac636f5820b2f88f75a1383f14d713.tar.xz
libbu++-e35e62a080ac636f5820b2f88f75a1383f14d713.zip
Process is working much better, it actually follows the guidelines for most of
it's functions now, such as isEos and whotnot, although it won't work in non- blocking mode yet, and I'm still trying to figure out a good way to have it deal with both stdout and stderr.
Diffstat (limited to '')
-rw-r--r--src/process.cpp17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/process.cpp b/src/process.cpp
index bea5932..9340647 100644
--- a/src/process.cpp
+++ b/src/process.cpp
@@ -94,7 +94,13 @@ void Bu::Process::close()
94 94
95size_t Bu::Process::read( void *pBuf, size_t nBytes ) 95size_t Bu::Process::read( void *pBuf, size_t nBytes )
96{ 96{
97 return TEMP_FAILURE_RETRY( ::read( iStdOut, pBuf, nBytes ) ); 97 size_t nRead = TEMP_FAILURE_RETRY( ::read( iStdOut, pBuf, nBytes ) );
98 if( nRead == 0 )
99 {
100 close();
101 return 0;
102 }
103 return nRead;
98 /* 104 /*
99 size_t iTotal = 0; 105 size_t iTotal = 0;
100 for(;;) 106 for(;;)
@@ -162,12 +168,12 @@ void Bu::Process::setPosEnd( long )
162 168
163bool Bu::Process::isEos() 169bool Bu::Process::isEos()
164{ 170{
165 return false; 171 return (iPid == 0);
166} 172}
167 173
168bool Bu::Process::isOpen() 174bool Bu::Process::isOpen()
169{ 175{
170 return true; 176 return (iPid != 0);
171} 177}
172 178
173void Bu::Process::flush() 179void Bu::Process::flush()
@@ -212,3 +218,8 @@ void Bu::Process::setBlocking( bool bBlocking )
212 fcntl( iStdOut, F_SETFL, fcntl( iStdOut, F_GETFL, 0 )|O_NONBLOCK ); 218 fcntl( iStdOut, F_SETFL, fcntl( iStdOut, F_GETFL, 0 )|O_NONBLOCK );
213} 219}
214 220
221pid_t Bu::Process::getPid()
222{
223 return iPid;
224}
225