Clean up the agent socket and working files when a signal ends the tool (closes #17) #30

Merged
clawbot merged 1 commits from issue-17-signal-cleanup into next 2026-09-21 16:58:25 +02:00
1 Commits
Author SHA1 Message Date
sneak a4a15c162e Clean up the agent socket and working files when a signal ends the tool (closes #17)
check / check (push) Successful in 42s
Main ran the command tree on a background context, so SIGINT, SIGTERM or
SIGHUP killed the process before the deferred cleanup ran: the agent's
temporary directory and socket, and the install working directory, were
left behind.

Main now runs the tree on a signal.NotifyContext for those three signals.
A signal cancels the context, which ends the child ssh or sftp started
with exec.CommandContext, and the deferred cleanup then runs. The exit
status after a signal stays 1 unless ssh reported one of its own.

For "ssh to" the child is cancelled with SIGTERM rather than the default
kill, so ssh restores the terminal before it goes.

Model: opus-4-8
2026-09-21 14:26:00 +00:00