summaryrefslogtreecommitdiff
path: root/src/libs/dutil/WixToolset.DUtil/procutil.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/libs/dutil/WixToolset.DUtil/procutil.cpp')
-rw-r--r--src/libs/dutil/WixToolset.DUtil/procutil.cpp42
1 files changed, 18 insertions, 24 deletions
diff --git a/src/libs/dutil/WixToolset.DUtil/procutil.cpp b/src/libs/dutil/WixToolset.DUtil/procutil.cpp
index 340a0cda..29f575ae 100644
--- a/src/libs/dutil/WixToolset.DUtil/procutil.cpp
+++ b/src/libs/dutil/WixToolset.DUtil/procutil.cpp
@@ -17,6 +17,7 @@
17#define ProcExitOnInvalidHandleWithLastError(p, x, s, ...) ExitOnInvalidHandleWithLastErrorSource(DUTIL_SOURCE_PROCUTIL, p, x, s, __VA_ARGS__) 17#define ProcExitOnInvalidHandleWithLastError(p, x, s, ...) ExitOnInvalidHandleWithLastErrorSource(DUTIL_SOURCE_PROCUTIL, p, x, s, __VA_ARGS__)
18#define ProcExitOnWin32Error(e, x, s, ...) ExitOnWin32ErrorSource(DUTIL_SOURCE_PROCUTIL, e, x, s, __VA_ARGS__) 18#define ProcExitOnWin32Error(e, x, s, ...) ExitOnWin32ErrorSource(DUTIL_SOURCE_PROCUTIL, e, x, s, __VA_ARGS__)
19#define ProcExitOnGdipFailure(g, x, s, ...) ExitOnGdipFailureSource(DUTIL_SOURCE_PROCUTIL, g, x, s, __VA_ARGS__) 19#define ProcExitOnGdipFailure(g, x, s, ...) ExitOnGdipFailureSource(DUTIL_SOURCE_PROCUTIL, g, x, s, __VA_ARGS__)
20#define ProcExitOnWaitObjectFailure(x, b, s, ...) ExitOnWaitObjectFailureSource(DUTIL_SOURCE_PROCUTIL, x, b, s, __VA_ARGS__)
20 21
21 22
22// private functions 23// private functions
@@ -403,30 +404,25 @@ LExit:
403extern "C" HRESULT DAPI ProcWaitForCompletion( 404extern "C" HRESULT DAPI ProcWaitForCompletion(
404 __in HANDLE hProcess, 405 __in HANDLE hProcess,
405 __in DWORD dwTimeout, 406 __in DWORD dwTimeout,
406 __out DWORD *pReturnCode 407 __out_opt DWORD* pdwReturnCode
407 ) 408 )
408{ 409{
409 HRESULT hr = S_OK; 410 HRESULT hr = S_OK;
410 DWORD er = ERROR_SUCCESS; 411 BOOL fTimedOut = FALSE;
411 412
412 // Wait for everything to finish 413 // Wait for everything to finish.
413 er = ::WaitForSingleObject(hProcess, dwTimeout); 414 hr = AppWaitForSingleObject(hProcess, dwTimeout);
414 if (WAIT_FAILED == er) 415 ProcExitOnWaitObjectFailure(hr, fTimedOut, "Failed to wait for process to complete.");
415 { 416
416 ProcExitWithLastError(hr, "Failed to wait for process to complete."); 417 if (fTimedOut)
417 }
418 else if (WAIT_TIMEOUT == er)
419 { 418 {
420 ExitFunction1(hr = HRESULT_FROM_WIN32(er)); 419 hr = HRESULT_FROM_WIN32(WAIT_TIMEOUT);
421 } 420 }
422 421 else if (pdwReturnCode && !::GetExitCodeProcess(hProcess, pdwReturnCode))
423 if (!::GetExitCodeProcess(hProcess, &er))
424 { 422 {
425 ProcExitWithLastError(hr, "Failed to get process return code."); 423 ProcExitWithLastError(hr, "Failed to get process return code.");
426 } 424 }
427 425
428 *pReturnCode = er;
429
430LExit: 426LExit:
431 return hr; 427 return hr;
432} 428}
@@ -442,10 +438,10 @@ extern "C" HRESULT DAPI ProcWaitForIds(
442 ) 438 )
443{ 439{
444 HRESULT hr = S_OK; 440 HRESULT hr = S_OK;
445 DWORD er = ERROR_SUCCESS;
446 HANDLE hProcess = NULL; 441 HANDLE hProcess = NULL;
447 HANDLE * rghProcesses = NULL; 442 HANDLE* rghProcesses = NULL;
448 DWORD cProcesses = 0; 443 DWORD cProcesses = 0;
444 BOOL fTimedOut = FALSE;
449 445
450 rghProcesses = static_cast<HANDLE*>(MemAlloc(sizeof(DWORD) * cProcessIds, TRUE)); 446 rghProcesses = static_cast<HANDLE*>(MemAlloc(sizeof(DWORD) * cProcessIds, TRUE));
451 ProcExitOnNull(rgdwProcessIds, hr, E_OUTOFMEMORY, "Failed to allocate array for process ID Handles."); 447 ProcExitOnNull(rgdwProcessIds, hr, E_OUTOFMEMORY, "Failed to allocate array for process ID Handles.");
@@ -459,16 +455,14 @@ extern "C" HRESULT DAPI ProcWaitForIds(
459 } 455 }
460 } 456 }
461 457
462 er = ::WaitForMultipleObjects(cProcesses, rghProcesses, TRUE, dwMilliseconds); 458 hr = AppWaitForMultipleObjects(cProcesses, rghProcesses, TRUE, dwMilliseconds, NULL);
463 if (WAIT_FAILED == er) 459 ProcExitOnWaitObjectFailure(hr, fTimedOut, "Failed to wait for processes to complete.");
464 { 460
465 ProcExitWithLastError(hr, "Failed to wait for process to complete."); 461 if (fTimedOut)
466 }
467 else if (WAIT_TIMEOUT == er)
468 { 462 {
469 ProcExitOnWin32Error(er, hr, "Timed out while waiting for process to complete."); 463 ProcExitWithRootFailure(hr, HRESULT_FROM_WIN32(WAIT_TIMEOUT), "Timed out while waiting for processes to complete.");
470 } 464 }
471 465
472LExit: 466LExit:
473 if (rghProcesses) 467 if (rghProcesses)
474 { 468 {