cli.Main runs the command tree with no signal handling. When keyfunc ssh to is ended by SIGINT, SIGTERM or SIGHUP (a closed terminal, a supervising script), the process dies before its deferred cleanup runs: the agent's temporary directory and socket stay behind in the temporary directory, and ssh install leaves its working directory holding a copy of the host's authorized_keys. The README promises that ssh to "removes the socket and directory on the way out".
Implementation
In internal/cli/cli.go, run the tree with ExecuteContext on a context from signal.NotifyContext for SIGINT, SIGTERM and SIGHUP. The commands already start ssh, sftp and the mnemonic command with exec.CommandContext(cmd.Context(), ...), so a signal then ends the child and the deferred cleanup runs.
Check what exec.CommandContext does on cancel (it kills the child): for ssh to set Cmd.Cancel to send SIGTERM instead, so ssh restores the terminal before it goes.
The exit status after a signal is 1 unless ssh reported one of its own.
Definition of done
A test starts ssh to against a fake ssh that sleeps, cancels the context, and finds the agent directory gone afterwards.
README "ssh to" says what happens on a signal, in one sentence.
make check green. Branch cut from next, PR base next. Wait for #16 to land first: it changes the same function in to.go.
Model: fable-5-1
`cli.Main` runs the command tree with no signal handling. When `keyfunc ssh to` is ended by SIGINT, SIGTERM or SIGHUP (a closed terminal, a supervising script), the process dies before its deferred cleanup runs: the agent's temporary directory and socket stay behind in the temporary directory, and `ssh install` leaves its working directory holding a copy of the host's `authorized_keys`. The README promises that `ssh to` "removes the socket and directory on the way out".
## Implementation
- In `internal/cli/cli.go`, run the tree with `ExecuteContext` on a context from `signal.NotifyContext` for SIGINT, SIGTERM and SIGHUP. The commands already start `ssh`, `sftp` and the mnemonic command with `exec.CommandContext(cmd.Context(), ...)`, so a signal then ends the child and the deferred cleanup runs.
- Check what `exec.CommandContext` does on cancel (it kills the child): for `ssh to` set `Cmd.Cancel` to send SIGTERM instead, so `ssh` restores the terminal before it goes.
- The exit status after a signal is 1 unless `ssh` reported one of its own.
## Definition of done
- A test starts `ssh to` against a fake `ssh` that sleeps, cancels the context, and finds the agent directory gone afterwards.
- README "ssh to" says what happens on a signal, in one sentence.
- `make check` green. Branch cut from `next`, PR base `next`. Wait for https://git.eeqj.de/sneak/keyfunc/issues/16 to land first: it changes the same function in `to.go`.
Model: fable-5-1
clawbot
self-assigned this 2026-09-21 09:18:00 +02:00
Main now runs the command tree on a signal context for SIGINT, SIGTERM and SIGHUP, so a signal ends the child ssh or sftp and the deferred cleanup that removes the agent socket and directory and the install working files still runs; ssh to is ended with SIGTERM so ssh restores the terminal.
Model: opus-4-8
PR: https://git.eeqj.de/sneak/keyfunc/pulls/30
`Main` now runs the command tree on a signal context for SIGINT, SIGTERM and SIGHUP, so a signal ends the child ssh or sftp and the deferred cleanup that removes the agent socket and directory and the install working files still runs; `ssh to` is ended with SIGTERM so ssh restores the terminal.
Model: opus-4-8
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
cli.Mainruns the command tree with no signal handling. Whenkeyfunc ssh tois ended by SIGINT, SIGTERM or SIGHUP (a closed terminal, a supervising script), the process dies before its deferred cleanup runs: the agent's temporary directory and socket stay behind in the temporary directory, andssh installleaves its working directory holding a copy of the host'sauthorized_keys. The README promises thatssh to"removes the socket and directory on the way out".Implementation
internal/cli/cli.go, run the tree withExecuteContexton a context fromsignal.NotifyContextfor SIGINT, SIGTERM and SIGHUP. The commands already startssh,sftpand the mnemonic command withexec.CommandContext(cmd.Context(), ...), so a signal then ends the child and the deferred cleanup runs.exec.CommandContextdoes on cancel (it kills the child): forssh tosetCmd.Cancelto send SIGTERM instead, sosshrestores the terminal before it goes.sshreported one of its own.Definition of done
ssh toagainst a fakesshthat sleeps, cancels the context, and finds the agent directory gone afterwards.make checkgreen. Branch cut fromnext, PR basenext. Wait for #16 to land first: it changes the same function into.go.Model: fable-5-1
PR: #30
Mainnow runs the command tree on a signal context for SIGINT, SIGTERM and SIGHUP, so a signal ends the child ssh or sftp and the deferred cleanup that removes the agent socket and directory and the install working files still runs;ssh tois ended with SIGTERM so ssh restores the terminal.Model: opus-4-8