summaryrefslogtreecommitdiff
path: root/src/burn/engine/pipe.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/burn/engine/pipe.cpp')
-rw-r--r--src/burn/engine/pipe.cpp34
1 files changed, 16 insertions, 18 deletions
diff --git a/src/burn/engine/pipe.cpp b/src/burn/engine/pipe.cpp
index e6c9905b..9529ef40 100644
--- a/src/burn/engine/pipe.cpp
+++ b/src/burn/engine/pipe.cpp
@@ -422,6 +422,7 @@ extern "C" HRESULT PipeTerminateChildProcess(
422 HRESULT hr = S_OK; 422 HRESULT hr = S_OK;
423 BYTE* pbData = NULL; 423 BYTE* pbData = NULL;
424 SIZE_T cbData = 0; 424 SIZE_T cbData = 0;
425 BOOL fTimedOut = FALSE;
425 426
426 // Prepare the exit message. 427 // Prepare the exit message.
427 hr = BuffWriteNumber(&pbData, &cbData, dwParentExitCode); 428 hr = BuffWriteNumber(&pbData, &cbData, dwParentExitCode);
@@ -443,31 +444,28 @@ extern "C" HRESULT PipeTerminateChildProcess(
443 // If we were able to get a handle to the other process, wait for it to exit. 444 // If we were able to get a handle to the other process, wait for it to exit.
444 if (pConnection->hProcess) 445 if (pConnection->hProcess)
445 { 446 {
446 if (WAIT_FAILED == ::WaitForSingleObject(pConnection->hProcess, PIPE_WAIT_FOR_CONNECTION * PIPE_RETRY_FOR_CONNECTION)) 447 hr = AppWaitForSingleObject(pConnection->hProcess, PIPE_WAIT_FOR_CONNECTION * PIPE_RETRY_FOR_CONNECTION);
447 { 448 ExitOnWaitObjectFailure(hr, fTimedOut, "Failed to wait for child process exit.");
448 ExitWithLastError(hr, "Failed to wait for child process exit."); 449
449 } 450 AssertSz(!fTimedOut, "Timed out while waiting for child process to exit.");
451 }
450 452
451#ifdef DEBUG 453#ifdef DEBUG
454 if (pConnection->hProcess && !fTimedOut)
455 {
452 DWORD dwChildExitCode = 0; 456 DWORD dwChildExitCode = 0;
453 DWORD dwErrorCode = ERROR_SUCCESS; 457 HRESULT hrDebug = S_OK;
454 BOOL fReturnedExitCode = ::GetExitCodeProcess(pConnection->hProcess, &dwChildExitCode);
455 if (!fReturnedExitCode)
456 {
457 dwErrorCode = ::GetLastError(); // if the other process is elevated and we are not, then we'll get ERROR_ACCESS_DENIED.
458 458
459 // The unit test use a thread instead of a process so try to get the exit code from 459 hrDebug = CoreWaitForProcCompletion(pConnection->hProcess, 0, &dwChildExitCode);
460 // the thread because we failed to get it from the process. 460 if (E_ACCESSDENIED != hrDebug) // if the other process is elevated and we are not, then we'll get ERROR_ACCESS_DENIED.
461 if (ERROR_INVALID_HANDLE == dwErrorCode) 461 {
462 { 462 TraceError(hrDebug, "Failed to wait for child process completion.");
463 fReturnedExitCode = ::GetExitCodeThread(pConnection->hProcess, &dwChildExitCode);
464 }
465 } 463 }
466 AssertSz((fReturnedExitCode && dwChildExitCode == dwParentExitCode) || 464
467 (!fReturnedExitCode && ERROR_ACCESS_DENIED == dwErrorCode), 465 AssertSz(E_ACCESSDENIED == hrDebug || dwChildExitCode == dwParentExitCode,
468 "Child elevated process did not return matching exit code to parent process."); 466 "Child elevated process did not return matching exit code to parent process.");
469#endif
470 } 467 }
468#endif
471 469
472LExit: 470LExit:
473 return hr; 471 return hr;