From 7d1787d0b60db2bc5307d333a335d57feba7d43a Mon Sep 17 00:00:00 2001 From: KUOKA Yusuke Date: Thu, 27 Sep 2018 04:36:34 +0900 Subject: [PATCH] One Ctrl-C should exit helmfile gracefully (#369) Perhaps in latest commits I unexpectedly changed it to require double Ctrl-C to actually interrupt. This fixes it so that one Ctrl-C exists helmfile. On the way to the fix, I changed the exit-code to 128 + SIGNAL(2 for SIGINT, 15 for SIGTERM) according to common *nix commands. --- main.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index af091cc4..e09f6d8b 100644 --- a/main.go +++ b/main.go @@ -988,7 +988,14 @@ func (a *app) loadDesiredStateFromYaml(yaml []byte, file string, namespace strin sig := <-sigs errs := []error{fmt.Errorf("Received [%s] to shutdown ", sig)} - clean(st, errs) + _ = clean(st, errs) + // See http://tldp.org/LDP/abs/html/exitcodes.html + switch sig { + case syscall.SIGINT: + os.Exit(130) + case syscall.SIGTERM: + os.Exit(143) + } }() return st, nil