From 7d8cdc810c25baf53a6856291827a696ab520945 Mon Sep 17 00:00:00 2001 From: Martin Herkt Date: Mon, 6 Jan 2014 13:31:15 +0100 Subject: [PATCH] win32-console-wrapper: use child process exit code --- osdep/win32-console-wrapper.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/osdep/win32-console-wrapper.c b/osdep/win32-console-wrapper.c index 9d86ea3872..c8c297b482 100644 --- a/osdep/win32-console-wrapper.c +++ b/osdep/win32-console-wrapper.c @@ -34,10 +34,11 @@ void cr_perror(const wchar_t *prefix) LocalFree(error); } -void cr_runproc(wchar_t *name, wchar_t *cmdline) +int cr_runproc(wchar_t *name, wchar_t *cmdline) { STARTUPINFO si; PROCESS_INFORMATION pi; + DWORD retval = 1; ZeroMemory(&si, sizeof(si)); si.cb = sizeof(si); @@ -54,9 +55,12 @@ void cr_runproc(wchar_t *name, wchar_t *cmdline) cr_perror(L"CreateProcess"); } else { WaitForSingleObject(pi.hProcess, INFINITE); + GetExitCodeProcess(pi.hProcess, &retval); CloseHandle(pi.hProcess); CloseHandle(pi.hThread); } + + return (int)retval; } int wmain(int argc, wchar_t **argv, wchar_t **envp) @@ -68,7 +72,5 @@ int wmain(int argc, wchar_t **argv, wchar_t **envp) GetModuleFileNameW(NULL, exe, MAX_PATH); wcscpy(wcsrchr(exe, '.') + 1, L"exe"); - cr_runproc(exe, cmd); - - return 0; + return cr_runproc(exe, cmd); }