Skip to content

Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.

fix: Ctrl+C not terminating backend on Linux (#4316)

Roland Tannous08b587910157
diff --git a/cli/commands/studio.py b/cli/commands/studio.py
index 0f1c021873c..89b2227fa6d 100644
--- a/cli/commands/studio.py
+++ b/cli/commands/studio.py
@@ -144,7 +144,10 @@ def studio_default(
try:
if _shutdown_event is not None:
- _shutdown_event.wait()
+ # NOTE: Event.wait() without a timeout blocks at the C level
+ # on Linux, preventing Python from delivering SIGINT (Ctrl+C).
+ while not _shutdown_event.is_set():
+ _shutdown_event.wait(timeout = 1)
else:
while True:
time.sleep(1)
diff --git a/studio/backend/run.py b/studio/backend/run.py
index 3e2bdb5a9a0..2f186758ae3 100644
--- a/studio/backend/run.py
+++ b/studio/backend/run.py
@@ -270,5 +270,9 @@ if __name__ == "__main__":
if hasattr(signal, "SIGBREAK"):
signal.signal(signal.SIGBREAK, _signal_handler)
- # Keep running until shutdown signal
- _shutdown_event.wait()
+ # Keep running until shutdown signal.
+ # NOTE: Event.wait() without a timeout blocks at the C level on Linux,
+ # which prevents Python from delivering SIGINT (Ctrl+C). Using a
+ # short timeout in a loop lets the interpreter process pending signals.
+ while not _shutdown_event.is_set():
+ _shutdown_event.wait(timeout = 1)