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:
Andrey Smirnov 2020-10-02 22:50:48 +03:00 committed by talos-bot
parent 26aaf6af2c
commit 1332f17134

View File

@ -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:
}
}()