Signals end every command, not only ssh to and ssh install (closes #48)
check / check (push) Failing after 3s

SIGINT, SIGTERM and SIGHUP were caught for the whole run, but only the
ssh and sftp children acted on them: the mnemonic prompt waited for
Enter, and an interrupted `age encrypt -o` put the encryption of the
cut-off input in place. Now they end the tool at once, except where a
command cleans up first: `ssh to` and `ssh install` while ssh or sftp
runs, and `age encrypt -o` and `age decrypt -o` while they write, where
a signal up to a tenth of a second after the input ends still removes
the unfinished file and exits 1. Those commands catch only the signals
the tool was not started ignoring, so a run under nohup survives a
hangup.

Model: opus-5-5
This commit is contained in:
2026-10-04 07:52:57 +00:00
parent 1d1c8182be
commit 6300a48451
8 changed files with 332 additions and 49 deletions
+9
View File
@@ -13,6 +13,7 @@ import (
"strings"
"github.com/spf13/cobra"
"sneak.berlin/go/keyfunc/internal/cli/signals"
)
// Where the key goes on the host and what the file it arrives in is
@@ -62,6 +63,14 @@ func install() *cobra.Command {
return err
}
// From here on a signal cancels the context, which
// sftp runs under, instead of ending the tool, so sftp
// ends and the working directory is still removed.
ctx, stop := signals.Context(cmd.Context())
defer stop()
cmd.SetContext(ctx)
return add(cmd, args[0], args[1:], line)
},
}