Skip to content

Commit

Permalink
Merge pull request #60 from davidovich/davidovich/issue59
Browse files Browse the repository at this point in the history
listen on CTRL-C for proper process termination
  • Loading branch information
davidovich authored Aug 21, 2020
2 parents acc4e52 + 574ddfa commit 5e752c0
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import (
"fmt"
"os"
"os/exec"
"os/signal"
"syscall"

"github.com/davidovich/summon/cmd"
"github.com/davidovich/summon/pkg/summon"
Expand All @@ -40,6 +42,14 @@ func Main(args []string, box *packr.Box) int {
return 1
}

c := make(chan os.Signal)
signal.Notify(c, os.Interrupt, syscall.SIGTERM)
go func() {
for range c {
os.Exit(0)
}
}()

rootCmd := cmd.CreateRootCmd(s, os.Args)
err = rootCmd.Execute()

Expand Down

0 comments on commit 5e752c0

Please sign in to comment.