nix-eval-jobs: print evaluation results using writeToStdout
Lix blocks SIGPIPE, and std::cout ignores EPIPE (actually it probably stashes an error code in some flag that no one ever reads, with the same end result). Consequently, nix-eval-jobs would waste resources by continuing to evaluate even when the reader interested in the results has long gone away. Instead, use writeToStdout, which throws an error on EPIPE, leading to the process terminating as desired. Reported-by: Winter <winter@winter.cafe> Change-Id: I962c09bab582a8ed27dd41c01b1519876a6a6964
This commit is contained in:
committed by
alois31
parent
441f7db5f1
commit
df607dd39e
@@ -170,6 +170,6 @@ void rewriteAggregates(std::map<std::string, nix::JSON> &jobs,
|
||||
job["error"] = ss.str();
|
||||
}
|
||||
|
||||
std::cout << job.dump() << "\n" << std::flush;
|
||||
nix::logger->writeToStdout(job.dump());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -320,7 +320,7 @@ void collector(MyArgs &myArgs, Sync<State> &state_,
|
||||
auto named = response.find("namedConstituents");
|
||||
if (named == response.end() || named->empty()) {
|
||||
response.erase("namedConstituents");
|
||||
std::cout << response.dump() << "\n" << std::flush;
|
||||
logger->writeToStdout(response.dump());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -421,14 +421,14 @@ int main(int argc, char **argv) {
|
||||
state->jobs[e.a]["error"] = e.message();
|
||||
state->jobs[e.b]["error"] = e.message();
|
||||
|
||||
std::cout << state->jobs[e.a].dump() << "\n"
|
||||
<< state->jobs[e.b].dump() << "\n";
|
||||
logger->writeToStdout(state->jobs[e.a].dump());
|
||||
logger->writeToStdout(state->jobs[e.b].dump());
|
||||
|
||||
for (const auto &jobName : e.remainingAggregates) {
|
||||
state->jobs[jobName]["error"] =
|
||||
"Skipping aggregate because of a dependency "
|
||||
"cycle";
|
||||
std::cout << state->jobs[jobName].dump() << "\n";
|
||||
logger->writeToStdout(state->jobs[jobName].dump());
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user