Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf3fd256

Browse files
committed
fix: Restore terminal on interrupt when connecting
Fixes#1292.
1 parent568574c commitf3fd256

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

‎cli/cliui/agent.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import (
44
"context"
55
"fmt"
66
"io"
7+
"os"
8+
"os/signal"
79
"sync"
810
"time"
911

@@ -46,6 +48,22 @@ func Agent(ctx context.Context, writer io.Writer, opts AgentOptions) error {
4648
spin.Start()
4749
deferspin.Stop()
4850

51+
ctx,cancelFunc:=context.WithCancel(ctx)
52+
defercancelFunc()
53+
stopSpin:=make(chan os.Signal,1)
54+
signal.Notify(stopSpin,os.Interrupt)
55+
defersignal.Stop(stopSpin)
56+
gofunc() {
57+
select {
58+
case<-ctx.Done():
59+
return
60+
case<-stopSpin:
61+
}
62+
signal.Stop(stopSpin)
63+
spin.Stop()
64+
os.Exit(1)
65+
}()
66+
4967
ticker:=time.NewTicker(opts.FetchInterval)
5068
deferticker.Stop()
5169
timer:=time.NewTimer(opts.WarnInterval)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp