diff options
Diffstat (limited to 'main.go')
-rw-r--r-- | main.go | 15 |
1 files changed, 15 insertions, 0 deletions
@@ -26,6 +26,7 @@ import ( "regexp" "sort" "strings" + "syscall" "text/tabwriter" "gerrit.automotivelinux.org/gerrit/src/xds/xds-agent.git/lib/xaapiv1" @@ -324,6 +325,20 @@ func main() { // Start signals monitoring routine MonitorSignals() + // Default callback to handle interrupt signal + // Maybe be overwritten by some subcommand (eg. targets commands) + err := OnSignals(func(sig os.Signal) { + Log.Debugf("Send signal %v (from main)", sig) + if IsInterruptSignal(sig) { + err := cli.NewExitError("Interrupted\n", int(syscall.EINTR)) + cli.HandleExitCoder(err) + } + }) + if err != nil { + cli.NewExitError(err.Error(), 1) + return + } + // Run the cli app app.Run(os.Args) } |