1 Commits
Author SHA1 Message Date
sneak 5045bac92f Exit 130 and say so when a command is interrupted (closes #267)
check / check (push) Waiting to run
Ctrl-C or SIGTERM during snapshot create, restore or verify exited 0
with no error line (1, also silent, under snapshot verify --json), so
an unfinished --cron backup looked like a success. RunOperation now
counts an op as interrupted when the Vaultik context was cancelled
before it returned, rather than when its error wraps context.Canceled,
which verify --json does not. Entry prints "interrupted before the
command finished" on stderr for it and returns 130, under --cron and
--json too.

SIGTERM also gives 130, as the issue asks, not 143.
The test does not reach the branch for an op still running when the
30s shutdown timeout ends.

Model: opus-5-5
2026-10-07 17:28:24 +00:00
+12 -1
View File
@@ -94,7 +94,9 @@ func interruptOnFirstRequest(t *testing.T, requestArrived <-chan struct{}) {
testEnded := make(chan struct{})
senderDone := make(chan struct{})
// The sender must have stopped before the test stops catching SIGINT.
// Stop catching SIGINT only after the sender has returned. The sender
// waits for each SIGINT it sends to arrive on caught; one still on
// its way after signal.Stop would kill the test binary.
t.Cleanup(func() {
close(testEnded)
<-senderDone
@@ -114,6 +116,13 @@ func interruptOnFirstRequest(t *testing.T, requestArrived <-chan struct{}) {
defer ticker.Stop()
for {
// Empty caught, so that the receive below waits for this
// SIGINT rather than an earlier one.
select {
case <-caught:
default:
}
sendErr := self.Signal(os.Interrupt)
if sendErr != nil {
t.Errorf("sending SIGINT: %v", sendErr)
@@ -121,6 +130,8 @@ func interruptOnFirstRequest(t *testing.T, requestArrived <-chan struct{}) {
return
}
<-caught
select {
case <-testEnded:
return