Put the terminal back when a signal ends the mnemonic prompt (closes #91)
check / check (push) Waiting to run

A SIGINT, SIGTERM or SIGHUP at the mnemonic prompt killed the tool
with echo still off. The prompt now catches them with signals.Notify
from before echo goes off, and reads the line in a goroutine. Once the
line is read or a signal arrives, it puts the terminal settings back
and stops catching; if a signal has arrived by then, it sends the tool
the same signal again, so the tool is still ended by it (130 for SIGINT
in a shell). A test sends SIGINT at the prompt on a pseudo-terminal.

The signals package moves from internal/cli to internal/signals, since
the mnemonic prompt now uses it as well.

Unchanged: the Windows prompt, which uses term.ReadPassword.

Model: opus-5-5
This commit is contained in:
2026-10-14 23:05:41 +00:00
parent a08eb28359
commit c3cc26c721
8 changed files with 175 additions and 52 deletions
+1 -1
View File
@@ -10,8 +10,8 @@ import (
"syscall"
"github.com/spf13/cobra"
"sneak.berlin/go/keyfunc/internal/cli/signals"
"sneak.berlin/go/keyfunc/internal/mnemonic"
"sneak.berlin/go/keyfunc/internal/signals"
)
// StatusError says the tool should end with the status ssh ended with.