apply treefmt

This commit is contained in:
Jörg Thalheim 2023-12-16 11:44:02 +01:00
parent b4f7eb3c77
commit 093b8ce5cc
2 changed files with 16 additions and 14 deletions

View file

@ -113,13 +113,14 @@ void handleBrokenWorkerPipe(Proc &proc, std::string_view msg) {
int rc = waitpid(pid, &status, WNOHANG); int rc = waitpid(pid, &status, WNOHANG);
if (rc == 0) { if (rc == 0) {
kill(pid, SIGKILL); kill(pid, SIGKILL);
throw Error( throw Error("BUG: while %s, worker pipe got closed but evaluation "
"BUG: while %s, worker pipe got closed but evaluation worker still running?", "worker still running?",
msg); msg);
} else if (rc == -1) { } else if (rc == -1) {
kill(pid, SIGKILL); kill(pid, SIGKILL);
throw Error("BUG: while %s, waitpid for evaluation worker failed: %s", throw Error(
msg, strerror(errno)); "BUG: while %s, waitpid for evaluation worker failed: %s", msg,
strerror(errno));
} else { } else {
if (WIFEXITED(status)) { if (WIFEXITED(status)) {
if (WEXITSTATUS(status) == 1) { if (WEXITSTATUS(status) == 1) {
@ -128,12 +129,12 @@ void handleBrokenWorkerPipe(Proc &proc, std::string_view msg) {
"(possibly an infinite recursion)", "(possibly an infinite recursion)",
msg); msg);
} }
throw Error("while %s, evaluation worker exited with %d", throw Error("while %s, evaluation worker exited with %d", msg,
msg, WEXITSTATUS(status)); WEXITSTATUS(status));
} else if (WIFSIGNALED(status)) { } else if (WIFSIGNALED(status)) {
if (WTERMSIG(status) == SIGKILL) { if (WTERMSIG(status) == SIGKILL) {
throw Error( throw Error("while %s, evaluation worker got killed by "
"while %s, evaluation worker got killed by SIGKILL, maybe " "SIGKILL, maybe "
"memory limit reached?", "memory limit reached?",
msg); msg);
} }
@ -147,7 +148,7 @@ void handleBrokenWorkerPipe(Proc &proc, std::string_view msg) {
std::string joinAttrPath(json &attrPath) { std::string joinAttrPath(json &attrPath) {
std::string joined; std::string joined;
for (auto& element : attrPath) { for (auto &element : attrPath) {
if (!joined.empty()) { if (!joined.empty()) {
joined += '.'; joined += '.';
} }
@ -220,7 +221,8 @@ void collector(Sync<State> &state_, std::condition_variable &wakeup) {
/* Wait for the response. */ /* Wait for the response. */
auto respString = fromReader->readLine(); auto respString = fromReader->readLine();
if (respString.empty()) { if (respString.empty()) {
auto msg = "reading result for attrPath '" + joinAttrPath(attrPath) + "'"; auto msg = "reading result for attrPath '" +
joinAttrPath(attrPath) + "'";
handleBrokenWorkerPipe(*proc.get(), msg); handleBrokenWorkerPipe(*proc.get(), msg);
} }
json response; json response;

View file

@ -116,5 +116,5 @@ def test_recursion_error() -> None:
) )
assert res.returncode == 1 assert res.returncode == 1
print(res.stderr) print(res.stderr)
assert 'packageWithInfiniteRecursion' in res.stderr assert "packageWithInfiniteRecursion" in res.stderr
assert "possible infinite recursion" in res.stderr assert "possible infinite recursion" in res.stderr