1
0
mirror of https://github.com/golang/go synced 2024-11-12 06:20:22 -07:00

dist: prevent recusive loop on windows when fatal() is called.

Fixes #2931.

R=golang-dev, alex.brainman
CC=golang-dev, rsc
https://golang.org/cl/5651049
This commit is contained in:
Daniel Theophanes 2012-02-09 23:10:27 -05:00 committed by Russ Cox
parent 9bcfc57660
commit ef1d2a32ea

View File

@ -371,6 +371,19 @@ genrun(Buf *b, char *dir, int mode, Vec *argv, int wait)
bfree(&cmd);
}
// closes the background job for bgwait1
static void
bgwaitclose(int i)
{
if(i < 0 || i >= nbg)
return;
CloseHandle(bg[i].pi.hProcess);
CloseHandle(bg[i].pi.hThread);
bg[i] = bg[--nbg];
}
// bgwait1 waits for a single background job
static void
bgwait1(void)
@ -391,14 +404,19 @@ bgwait1(void)
cmd = bg[i].cmd;
mode = bg[i].mode;
if(!GetExitCodeProcess(bg[i].pi.hProcess, &code))
if(!GetExitCodeProcess(bg[i].pi.hProcess, &code)) {
bgwaitclose(i);
fatal("GetExitCodeProcess: %s", errstr());
if(mode==CheckExit && code != 0)
fatal("FAILED: %s", cmd);
CloseHandle(bg[i].pi.hProcess);
CloseHandle(bg[i].pi.hThread);
return;
}
bg[i] = bg[--nbg];
if(mode==CheckExit && code != 0) {
bgwaitclose(i);
fatal("FAILED: %s", cmd);
return;
}
bgwaitclose(i);
}
void