aboutsummaryrefslogtreecommitdiff
path: root/src/stable/process.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/stable/process.cpp24
1 files changed, 13 insertions, 11 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