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 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.

Untested: a signal that comes just as the line is read.

Model: opus-5-5
This commit was merged in pull request #92.
This commit is contained in:
2026-10-15 01:35:42 +02:00
parent a08eb28359
commit 8bb3d949d9
8 changed files with 175 additions and 52 deletions
+3
View File
@@ -87,6 +87,9 @@ func init() {
// still runs, and "age encrypt -o" and "age decrypt -o" while they
// write a new file to rename over the named one, so the unfinished file
// is removed.
//
// At the mnemonic prompt the signal is caught only to put the terminal
// back, and then ends the tool as above.
func Main() int {
err := Root().Execute()
if err == nil {