fix: make CLI context exit immediately on second ^C
Bug was that it required three ^C to exit immediately instead of two. Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
This commit is contained in:
parent
26aaf6af2c
commit
1332f17134
@ -28,15 +28,11 @@ func WithContext(ctx context.Context, f func(context.Context) error) error {
|
||||
select {
|
||||
case <-sigCh:
|
||||
wrappedCtxCancel()
|
||||
case <-wrappedCtx.Done():
|
||||
return
|
||||
case <-exited:
|
||||
}
|
||||
|
||||
select {
|
||||
case <-sigCh:
|
||||
signal.Stop(sigCh)
|
||||
fmt.Fprintln(os.Stderr, "Signal received, aborting, press Ctrl+C once again to abort immediately...")
|
||||
case <-wrappedCtx.Done():
|
||||
return
|
||||
case <-exited:
|
||||
}
|
||||
}()
|
||||
|
Loading…
x
Reference in New Issue
Block a user