mirror of
https://github.com/golang/go
synced 2024-11-19 15:44:44 -07:00
[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 <bradfitz@golang.org>
This commit is contained in:
parent
eeebcd9db3
commit
3066d05498
@ -19,7 +19,7 @@ runcmd(char **argv)
|
|||||||
WinRune *r;
|
WinRune *r;
|
||||||
STARTUPINFOW si;
|
STARTUPINFOW si;
|
||||||
PROCESS_INFORMATION pi;
|
PROCESS_INFORMATION pi;
|
||||||
DWORD code;
|
DWORD code, lasterr;
|
||||||
|
|
||||||
fmtstrinit(&fmt);
|
fmtstrinit(&fmt);
|
||||||
for(i=0; argv[i]; i++) {
|
for(i=0; argv[i]; i++) {
|
||||||
@ -63,18 +63,24 @@ runcmd(char **argv)
|
|||||||
si.hStdError = GetStdHandle(STD_ERROR_HANDLE);
|
si.hStdError = GetStdHandle(STD_ERROR_HANDLE);
|
||||||
|
|
||||||
if(!CreateProcessW(nil, r, nil, nil, TRUE, 0, nil, nil, &si, &pi)) {
|
if(!CreateProcessW(nil, r, nil, nil, TRUE, 0, nil, nil, &si, &pi)) {
|
||||||
|
werrstr("CreateProcess failed: errno=%d", (int)GetLastError());
|
||||||
free(r);
|
free(r);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
free(r);
|
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;
|
return -1;
|
||||||
|
}
|
||||||
i = GetExitCodeProcess(pi.hProcess, &code);
|
i = GetExitCodeProcess(pi.hProcess, &code);
|
||||||
|
lasterr = GetLastError();
|
||||||
CloseHandle(pi.hProcess);
|
CloseHandle(pi.hProcess);
|
||||||
CloseHandle(pi.hThread);
|
CloseHandle(pi.hThread);
|
||||||
if(!i)
|
if(!i) {
|
||||||
|
werrstr("GetExitCodeProcess failed: errno=%d", (int)lasterr);
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
if(code != 0) {
|
if(code != 0) {
|
||||||
werrstr("unsuccessful exit status: %d", (int)code);
|
werrstr("unsuccessful exit status: %d", (int)code);
|
||||||
return -1;
|
return -1;
|
||||||
|
Loading…
Reference in New Issue
Block a user