Skip to content

Commit

Permalink
fix: readline exit behaviour
Browse files Browse the repository at this point in the history
Send SIGINT so all processess in the group also shut down

fixes: #2970
  • Loading branch information
stuartwdouglas committed Oct 3, 2024
1 parent e534f24 commit 4a89a2b
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion internal/terminal/interactive.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"io"
"os"
"strings"
"syscall"

"github.com/alecthomas/kong"
"github.com/chzyer/readline"
Expand All @@ -33,7 +34,7 @@ func RunInteractiveConsole(ctx context.Context, k *kong.Kong, binder KongContext
InterruptPrompt: "^C",
AutoComplete: &FTLCompletion{app: k, ctx: ctx, client: client},
Listener: &ExitListener{cancel: func() {
os.Exit(0)
_ = syscall.Kill(-syscall.Getpid(), syscall.SIGINT) //nolint:forcetypeassert,errcheck // best effort
}},
})
sm := FromContext(ctx)
Expand Down Expand Up @@ -71,6 +72,7 @@ func RunInteractiveConsole(ctx context.Context, k *kong.Kong, binder KongContext
for {
line, err := l.Readline()
if errors.Is(err, readline.ErrInterrupt) {

if len(line) == 0 {
break
}
Expand Down

0 comments on commit 4a89a2b

Please sign in to comment.