aboutsummaryrefslogtreecommitdiff
path: root/src/process.cpp
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2008-09-24 00:19:12 +0000
committerMike Buland <eichlan@xagasoft.com>2008-09-24 00:19:12 +0000
commit17df4c2b9616c29865b0d893cc797d4938a660a2 (patch)
treed31d62c5694279747909bbab2b8be93f01a7fb7b /src/process.cpp
parent5230927c4f087cf2dcaac4fb9ed133c1ff3e2269 (diff)
downloadlibbu++-17df4c2b9616c29865b0d893cc797d4938a660a2.tar.gz
libbu++-17df4c2b9616c29865b0d893cc797d4938a660a2.tar.bz2
libbu++-17df4c2b9616c29865b0d893cc797d4938a660a2.tar.xz
libbu++-17df4c2b9616c29865b0d893cc797d4938a660a2.zip
Wholly crap. Added the Fifo, fixed a bunch of bugs, made things more standard,
now I have a huge list of new functions to add. Also, we discovered that if we add -W it produces more warnings, warnings about things that we'd like to know about. I have a lot of work to go fixing that...
Diffstat (limited to 'src/process.cpp')
-rw-r--r--src/process.cpp11
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
16Bu::Process::Process( const char *sName, char *const argv[] ) 17Bu::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
82size_t Bu::Process::read( void *pBuf, size_t nBytes ) 84size_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
125size_t Bu::Process::write( const void *pBuf, size_t nBytes ) 130size_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
130long Bu::Process::tell() 135long Bu::Process::tell()
@@ -190,5 +195,9 @@ bool Bu::Process::isBlocking()
190 195
191void Bu::Process::setBlocking( bool bBlocking ) 196void 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