Commit ef1d2a32 authored by Daniel Theophanes's avatar Daniel Theophanes Committed by Russ Cox

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
parent 9bcfc576
......@@ -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)
return;
}
if(mode==CheckExit && code != 0) {
bgwaitclose(i);
fatal("FAILED: %s", cmd);
CloseHandle(bg[i].pi.hProcess);
CloseHandle(bg[i].pi.hThread);
return;
}
bg[i] = bg[--nbg];
bgwaitclose(i);
}
void
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment