summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2012-04-03 16:43:54 +0000
committerMike Buland <eichlan@xagasoft.com>2012-04-03 16:43:54 +0000
commit9fa0f9cea3b92b3d44257a612731456fea629c68 (patch)
treeca39eb93e49b9965f09d2e86fdac0f8fe9a2aba4 /src
parent618ffae80369dbf00d505020234d3fe0c4966e85 (diff)
downloadlibbu++-9fa0f9cea3b92b3d44257a612731456fea629c68.tar.gz
libbu++-9fa0f9cea3b92b3d44257a612731456fea629c68.tar.bz2
libbu++-9fa0f9cea3b92b3d44257a612731456fea629c68.tar.xz
libbu++-9fa0f9cea3b92b3d44257a612731456fea629c68.zip
Process doesn't include win32.h now.
Diffstat (limited to 'src')
-rw-r--r--src/stable/process.cpp24
-rw-r--r--src/stable/process.h6
2 files changed, 14 insertions, 16 deletions
diff --git a/src/stable/process.cpp b/src/stable/process.cpp
index 92e7086..b19205c 100644
--- a/src/stable/process.cpp
+++ b/src/stable/process.cpp
@@ -130,6 +130,7 @@ void Bu::Process::gexec( Flags eFlags, const char *sName, char *const argv[] )
130 HANDLE hChildStd_IN_Wr; 130 HANDLE hChildStd_IN_Wr;
131 HANDLE hChildStd_OUT_Rd; 131 HANDLE hChildStd_OUT_Rd;
132 HANDLE hChildStd_OUT_Wr; 132 HANDLE hChildStd_OUT_Wr;
133 PROCESS_INFORMATION piProcInfo;
133 134
134 saAttr.nLength = sizeof(SECURITY_ATTRIBUTES); 135 saAttr.nLength = sizeof(SECURITY_ATTRIBUTES);
135 saAttr.bInheritHandle = TRUE; 136 saAttr.bInheritHandle = TRUE;
@@ -165,7 +166,7 @@ void Bu::Process::gexec( Flags eFlags, const char *sName, char *const argv[] )
165 BOOL bSuccess = FALSE; 166 BOOL bSuccess = FALSE;
166 167
167 // Set up members of the PROCESS_INFORMATION structure. 168 // Set up members of the PROCESS_INFORMATION structure.
168 ZeroMemory( &pd.piProcInfo, sizeof(PROCESS_INFORMATION) ); 169 ZeroMemory( &piProcInfo, sizeof(PROCESS_INFORMATION) );
169 170
170 // Set up members of the STARTUPINFO structure. 171 // Set up members of the STARTUPINFO structure.
171 // This structure specifies the STDIN and STDOUT handles for redirection. 172 // This structure specifies the STDIN and STDOUT handles for redirection.
@@ -195,7 +196,7 @@ void Bu::Process::gexec( Flags eFlags, const char *sName, char *const argv[] )
195 NULL, // use parent's environment 196 NULL, // use parent's environment
196 NULL, // use parent's current directory 197 NULL, // use parent's current directory
197 &siStartInfo, // STARTUPINFO pointer 198 &siStartInfo, // STARTUPINFO pointer
198 &pd.piProcInfo ); // receives PROCESS_INFORMATION 199 &piProcInfo ); // receives PROCESS_INFORMATION
199 200
200 // If an error occurs, exit the application. 201 // If an error occurs, exit the application.
201 if ( ! bSuccess ) 202 if ( ! bSuccess )
@@ -210,7 +211,8 @@ void Bu::Process::gexec( Flags eFlags, const char *sName, char *const argv[] )
210 // of the child process, for example. 211 // of the child process, for example.
211 212
212 //CloseHandle(pData->pd.piProcInfo.hProcess); 213 //CloseHandle(pData->pd.piProcInfo.hProcess);
213 CloseHandle(pd.piProcInfo.hThread); 214 CloseHandle(piProcInfo.hThread);
215 pd.hProcess = piProcInfo.hProcess;
214 216
215 // Close the ends we can't use 217 // Close the ends we can't use
216 CloseHandle( hChildStd_OUT_Wr ); 218 CloseHandle( hChildStd_OUT_Wr );
@@ -284,15 +286,15 @@ void Bu::Process::close()
284 286
285 pd.hStdIn = pd.hStdOut = pd.hStdErr = NULL; 287 pd.hStdIn = pd.hStdOut = pd.hStdErr = NULL;
286 288
287 if( !TerminateProcess(pd.piProcInfo.hProcess, 1) ) 289 if( !TerminateProcess(pd.hProcess, 1) )
288 { 290 {
289 throw Bu::ExceptionBase("Error closing process."); 291 throw Bu::ExceptionBase("Error closing process.");
290 } 292 }
291 293
292 GetExitCodeProcess( pd.piProcInfo.hProcess, (PDWORD)&iProcStatus ); 294 GetExitCodeProcess( pd.hProcess, (PDWORD)&iProcStatus );
293 295
294 CloseHandle( pd.piProcInfo.hProcess ); 296 CloseHandle( pd.hProcess );
295 pd.piProcInfo.hProcess = NULL; 297 pd.hProcess = NULL;
296 } 298 }
297#else 299#else
298 if( pd.iPid ) 300 if( pd.iPid )
@@ -343,7 +345,7 @@ Bu::size Bu::Process::read( void *pBuf, Bu::size nBytes )
343 dwLen, &dwRead, NULL); 345 dwLen, &dwRead, NULL);
344// if( dwRead < dwLen ) 346// if( dwRead < dwLen )
345 { 347 {
346 bSuccess = GetExitCodeProcess( pd.piProcInfo.hProcess, &lExitCode ); 348 bSuccess = GetExitCodeProcess( pd.hProcess, &lExitCode );
347 if( lExitCode != STILL_ACTIVE ) 349 if( lExitCode != STILL_ACTIVE )
348 { 350 {
349 bStdOutEos = true; 351 bStdOutEos = true;
@@ -458,7 +460,7 @@ void Bu::Process::setPosEnd( Bu::size )
458bool Bu::Process::isEos() 460bool Bu::Process::isEos()
459{ 461{
460#ifdef WIN32 462#ifdef WIN32
461 return (pd.piProcInfo.hProcess == NULL); 463 return (pd.hProcess == NULL);
462#else 464#else
463 return (pd.iPid == 0); 465 return (pd.iPid == 0);
464#endif 466#endif
@@ -573,7 +575,7 @@ bool Bu::Process::isRunning()
573{ 575{
574#ifdef WIN32 576#ifdef WIN32
575 DWORD lExitCode; 577 DWORD lExitCode;
576 GetExitCodeProcess( pd.piProcInfo.hProcess, &lExitCode ); 578 GetExitCodeProcess( pd.hProcess, &lExitCode );
577 if( lExitCode != STILL_ACTIVE ) 579 if( lExitCode != STILL_ACTIVE )
578 checkClose(); 580 checkClose();
579#else 581#else
@@ -607,7 +609,7 @@ pid_t Bu::Process::getPid()
607bool Bu::Process::childExited() 609bool Bu::Process::childExited()
608{ 610{
609#ifdef WIN32 611#ifdef WIN32
610 return pd.piProcInfo.hProcess != NULL; 612 return pd.hProcess != NULL;
611#else 613#else
612 return WIFEXITED( iProcStatus ); 614 return WIFEXITED( iProcStatus );
613#endif 615#endif
diff --git a/src/stable/process.h b/src/stable/process.h
index f010633..1ca6dd2 100644
--- a/src/stable/process.h
+++ b/src/stable/process.h
@@ -8,10 +8,6 @@
8#ifndef BU_PROCESS_H 8#ifndef BU_PROCESS_H
9#define BU_PROCESS_H 9#define BU_PROCESS_H
10 10
11#ifdef WIN32
12#include <windows.h>
13#endif
14
15#include <stdint.h> 11#include <stdint.h>
16#include <sys/types.h> 12#include <sys/types.h>
17 13
@@ -147,7 +143,7 @@ namespace Bu
147 void *hStdIn; 143 void *hStdIn;
148 void *hStdOut; 144 void *hStdOut;
149 void *hStdErr; 145 void *hStdErr;
150 PROCESS_INFORMATION piProcInfo; 146 void *hProcess;
151#else 147#else
152 int iStdIn; 148 int iStdIn;
153 int iStdOut; 149 int iStdOut;