From 8f5d0d4c05f8f3d1553b0527af5306010f0ada44 Mon Sep 17 00:00:00 2001 From: eldritch horrors <pennae@lix.systems> Date: Mon, 4 Mar 2024 07:40:17 +0100 Subject: [PATCH] Merge pull request #9687 from edolstra/withFramedSink-ctrl-c-hang withFramedSink(): Receive interrupts on the stderr thread (cherry picked from commit 965cfe96886c988c3aa94bfc7fefdd37325f4536) Change-Id: I8320a96957c01ec0e3450d1b3ae38a3baff78d49 --- src/libstore/build/substitution-goal.cc | 2 ++ src/libstore/remote-store.cc | 1 + src/libutil/thread-pool.cc | 2 ++ 3 files changed, 5 insertions(+) diff --git a/src/libstore/build/substitution-goal.cc b/src/libstore/build/substitution-goal.cc index 93867007d..e77772f96 100644 --- a/src/libstore/build/substitution-goal.cc +++ b/src/libstore/build/substitution-goal.cc @@ -217,6 +217,8 @@ void PathSubstitutionGoal::tryToRun() thr = std::thread([this]() { try { + ReceiveInterrupts receiveInterrupts; + /* Wake up the worker loop when we're done. */ Finally updateStats([this]() { outPipe.writeSide.close(); }); diff --git a/src/libstore/remote-store.cc b/src/libstore/remote-store.cc index dda119809..2f4933577 100644 --- a/src/libstore/remote-store.cc +++ b/src/libstore/remote-store.cc @@ -1071,6 +1071,7 @@ void RemoteStore::ConnectionHandle::withFramedSink(std::function<void(Sink & sin std::thread stderrThread([&]() { try { + ReceiveInterrupts receiveInterrupts; processStderr(nullptr, nullptr, false); } catch (...) { ex = std::current_exception(); diff --git a/src/libutil/thread-pool.cc b/src/libutil/thread-pool.cc index dc4067f1b..6513234ba 100644 --- a/src/libutil/thread-pool.cc +++ b/src/libutil/thread-pool.cc @@ -77,6 +77,8 @@ void ThreadPool::process() void ThreadPool::doWork(bool mainThread) { + ReceiveInterrupts receiveInterrupts; + if (!mainThread) interruptCheck = [&]() { return (bool) quit; };