diff --git a/src/libmain/progress-bar.cc b/src/libmain/progress-bar.cc index f0270df04..548b3d3a0 100644 --- a/src/libmain/progress-bar.cc +++ b/src/libmain/progress-bar.cc @@ -558,7 +558,14 @@ std::optional ProgressBar::ask(std::string_view msg) auto state(state_.lock()); if (state->paused > 0 || !isatty(STDIN_FILENO)) return {}; std::cerr << fmt("\r\e[K%s ", msg); - auto s = trim(readLine(STDIN_FILENO)); + auto s = [&]() { + try { + return trim(readLine(STDIN_FILENO)); + } catch (Error & e) { + e.addTrace({}, "while trying to read from STDIN to ask something"); + throw; + } + }(); if (s.size() != 1) return {}; draw(*state, {}); return s[0]; diff --git a/src/libstore/platform/linux.cc b/src/libstore/platform/linux.cc index 03b8bc0be..fba711144 100644 --- a/src/libstore/platform/linux.cc +++ b/src/libstore/platform/linux.cc @@ -930,7 +930,14 @@ Pid LinuxLocalDerivationGoal::startChild(std::function openSlave) userNamespaceSync.writeSide.reset(); }); - auto ss = tokenizeString>(readLine(sendPid.readSide.get())); + auto ss = [&]() { + try { + return tokenizeString>(readLine(sendPid.readSide.get())); + } catch (Error & e) { + e.addTrace({}, "while... how am I supposed to know?"); + throw; + } + }(); assert(ss.size() == 1); Pid pid = Pid{string2Int(ss[0]).value()};