From ae788a17f8371de0d60b7b9d713bdb8261fa6cd2 Mon Sep 17 00:00:00 2001 From: chengyongru <2755839590@qq.com> Date: Mon, 2 Mar 2026 11:03:54 +0800 Subject: [PATCH 1/2] chore: add .worktrees to .gitignore Co-Authored-By: Claude Opus 4.6 --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index d7b930d..a543251 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +.worktrees/ .assets .env *.pyc From aed1ef55298433a963474d8fbdcf0b203945ffb5 Mon Sep 17 00:00:00 2001 From: chengyongru <2755839590@qq.com> Date: Mon, 2 Mar 2026 11:04:53 +0800 Subject: [PATCH 2/2] fix: add SIGTERM, SIGHUP handling and ignore SIGPIPE - Add handler for SIGTERM to prevent "Terminated" message on Linux - Add handler for SIGHUP for terminal closure handling - Ignore SIGPIPE to prevent silent process termination - Change os._exit(0) to sys.exit(0) for proper cleanup Fixes issue #1365 Co-Authored-By: Claude Opus 4.6 --- nanobot/cli/commands.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/nanobot/cli/commands.py b/nanobot/cli/commands.py index 2662e9f..8c53992 100644 --- a/nanobot/cli/commands.py +++ b/nanobot/cli/commands.py @@ -501,12 +501,17 @@ def agent( else: cli_channel, cli_chat_id = "cli", session_id - def _exit_on_sigint(signum, frame): + def _handle_signal(signum, frame): + sig_name = signal.Signals(signum).name _restore_terminal() - console.print("\nGoodbye!") - os._exit(0) + console.print(f"\nReceived {sig_name}, goodbye!") + sys.exit(0) - signal.signal(signal.SIGINT, _exit_on_sigint) + signal.signal(signal.SIGINT, _handle_signal) + signal.signal(signal.SIGTERM, _handle_signal) + signal.signal(signal.SIGHUP, _handle_signal) + # Ignore SIGPIPE to prevent silent process termination when writing to closed pipes + signal.signal(signal.SIGPIPE, signal.SIG_IGN) async def run_interactive(): bus_task = asyncio.create_task(agent_loop.run())