Fix fatal "broken pipe" error when $NIX_BUILD_HOOK is missing

This commit is contained in:
Eelco Dolstra 2017-03-03 15:40:06 +01:00
parent ffcf9d24a6
commit 2f992692e2
No known key found for this signature in database
GPG key ID: 8170B4726D7198DE

View file

@ -1580,6 +1580,8 @@ HookReply DerivationGoal::tryBuildHook()
if (!worker.hook) if (!worker.hook)
worker.hook = std::make_unique<HookInstance>(); worker.hook = std::make_unique<HookInstance>();
try {
/* Tell the hook about system features (beyond the system type) /* Tell the hook about system features (beyond the system type)
required from the build machine. (The hook could parse the required from the build machine. (The hook could parse the
drv file itself, but this is easier.) */ drv file itself, but this is easier.) */
@ -1611,6 +1613,16 @@ HookReply DerivationGoal::tryBuildHook()
else if (reply != "accept") else if (reply != "accept")
throw Error(format("bad hook reply %1%") % reply); throw Error(format("bad hook reply %1%") % reply);
} catch (SysError & e) {
if (e.errNo == EPIPE) {
printError("build hook died unexpectedly: %s",
chomp(drainFD(worker.hook->fromHook.readSide.get())));
worker.hook = 0;
return rpDecline;
} else
throw;
}
printMsg(lvlTalkative, format("using hook to build path(s) %1%") % showPaths(missingPaths)); printMsg(lvlTalkative, format("using hook to build path(s) %1%") % showPaths(missingPaths));
hook = std::move(worker.hook); hook = std::move(worker.hook);