From 58e0e79e7c4df106b5a50399006be1c134995405 Mon Sep 17 00:00:00 2001 From: Radek Simko Date: Tue, 11 Jan 2022 11:21:35 +0000 Subject: [PATCH] fix: Catch OS agnostic interrupt signal (#755) As per docs (https://pkg.go.dev/os/signal#hdr-Windows) os.Interrupt is an OS-agnostic "signal" as opposed to syscall.SIGINT which is Unix-only. This should enable us to catch interrupts on Windows too, therefore do more graceful shutdowns and also write CPU profile. --- internal/cmd/inspect_module_command.go | 2 +- internal/cmd/serve_command.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/cmd/inspect_module_command.go b/internal/cmd/inspect_module_command.go index 0200543c..4c1b3b13 100644 --- a/internal/cmd/inspect_module_command.go +++ b/internal/cmd/inspect_module_command.go @@ -98,7 +98,7 @@ func (c *InspectModuleCommand) inspect(rootPath string) error { walker.SetLogger(c.logger) ctx, cancel := ictx.WithSignalCancel(context.Background(), - c.logger, syscall.SIGINT, syscall.SIGTERM) + c.logger, os.Interrupt, syscall.SIGTERM) defer cancel() walker.EnqueuePath(rootPath) diff --git a/internal/cmd/serve_command.go b/internal/cmd/serve_command.go index 305a5a61..012c4b00 100644 --- a/internal/cmd/serve_command.go +++ b/internal/cmd/serve_command.go @@ -96,7 +96,7 @@ func (c *ServeCommand) Run(args []string) int { } ctx, cancelFunc := lsctx.WithSignalCancel(context.Background(), logger, - syscall.SIGINT, syscall.SIGTERM) + os.Interrupt, syscall.SIGTERM) defer cancelFunc() // Setting this option as a CLI flag is deprecated