Merge PR #1400: fix: add SIGTERM, SIGHUP handling and ignore SIGPIPE

This commit is contained in:
Re-bin
2026-03-05 14:59:03 +00:00
2 changed files with 10 additions and 4 deletions

1
.gitignore vendored
View File

@@ -1,3 +1,4 @@
.worktrees/
.assets .assets
.env .env
*.pyc *.pyc

View File

@@ -517,12 +517,17 @@ def agent(
else: else:
cli_channel, cli_chat_id = "cli", session_id 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() _restore_terminal()
console.print("\nGoodbye!") console.print(f"\nReceived {sig_name}, goodbye!")
os._exit(0) 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(): async def run_interactive():
bus_task = asyncio.create_task(agent_loop.run()) bus_task = asyncio.create_task(agent_loop.run())