From 3066d05498fc2dfa20db896b52278dfb4f6e57d4 Mon Sep 17 00:00:00 2001 From: Alex Brainman Date: Fri, 30 Jan 2015 15:48:58 +1100 Subject: [PATCH] [dev.cc] lib9: add more error reporting to windows runcmd %r format prints nothing useful on windows (see issue 9722). Hopefully this will provide more clues about what happened. Change-Id: Ic553bbdcde0c3cbfffa3a28f2168d6e75694e2ac Reviewed-on: https://go-review.googlesource.com/3568 Reviewed-by: Brad Fitzpatrick --- src/lib9/run_windows.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/lib9/run_windows.c b/src/lib9/run_windows.c index 87875b42db..e3e1c25710 100644 --- a/src/lib9/run_windows.c +++ b/src/lib9/run_windows.c @@ -19,7 +19,7 @@ runcmd(char **argv) WinRune *r; STARTUPINFOW si; PROCESS_INFORMATION pi; - DWORD code; + DWORD code, lasterr; fmtstrinit(&fmt); for(i=0; argv[i]; i++) { @@ -63,18 +63,24 @@ runcmd(char **argv) si.hStdError = GetStdHandle(STD_ERROR_HANDLE); if(!CreateProcessW(nil, r, nil, nil, TRUE, 0, nil, nil, &si, &pi)) { + werrstr("CreateProcess failed: errno=%d", (int)GetLastError()); free(r); return -1; } free(r); - if(WaitForMultipleObjects(1, &pi.hProcess, FALSE, INFINITE) != 0) + if(WaitForMultipleObjects(1, &pi.hProcess, FALSE, INFINITE) != 0) { + werrstr("WaitForMultipleObjects failed: errno=%d", (int)GetLastError()); return -1; + } i = GetExitCodeProcess(pi.hProcess, &code); + lasterr = GetLastError(); CloseHandle(pi.hProcess); CloseHandle(pi.hThread); - if(!i) + if(!i) { + werrstr("GetExitCodeProcess failed: errno=%d", (int)lasterr); return -1; + } if(code != 0) { werrstr("unsuccessful exit status: %d", (int)code); return -1;