From ba6fc37173c2f0fae701482a3d1e758c1988ce04 Mon Sep 17 00:00:00 2001 From: Hank Donnay Date: Tue, 23 Jan 2024 09:13:53 -0600 Subject: [PATCH] clair: add platform-specific signals Signed-off-by: Hank Donnay --- cmd/clair/main.go | 2 +- cmd/clair/os_other.go | 7 +++++++ cmd/clair/os_unix.go | 10 ++++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 cmd/clair/os_other.go create mode 100644 cmd/clair/os_unix.go diff --git a/cmd/clair/main.go b/cmd/clair/main.go index f425e2bec8..03f19fd44a 100644 --- a/cmd/clair/main.go +++ b/cmd/clair/main.go @@ -100,7 +100,7 @@ func main() { auto.PrintLogs(ctx) // Signal handler, for orderly shutdown. - sig, stop := signal.NotifyContext(ctx, os.Interrupt) + sig, stop := signal.NotifyContext(ctx, append(platformShutdown, os.Interrupt)...) defer stop() zlog.Info(ctx).Msg("registered signal handler") go func() { diff --git a/cmd/clair/os_other.go b/cmd/clair/os_other.go new file mode 100644 index 0000000000..2a0aea4982 --- /dev/null +++ b/cmd/clair/os_other.go @@ -0,0 +1,7 @@ +//go:build !unix + +package main + +import "os" + +var platformShutdown = []os.Signal{} diff --git a/cmd/clair/os_unix.go b/cmd/clair/os_unix.go new file mode 100644 index 0000000000..c59bcfc051 --- /dev/null +++ b/cmd/clair/os_unix.go @@ -0,0 +1,10 @@ +//go:build unix + +package main + +import ( + "os" + "syscall" +) + +var platformShutdown = []os.Signal{syscall.SIGTERM}