summaryrefslogtreecommitdiffstats
path: root/main.go
diff options
context:
space:
mode:
Diffstat (limited to 'main.go')
-rw-r--r--main.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/main.go b/main.go
index 2dfd056..8d1e0eb 100644
--- a/main.go
+++ b/main.go
@@ -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)
}