Skip to content

Commit

Permalink
fix: Catch OS agnostic interrupt signal (hashicorp#755)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
radeksimko authored Jan 11, 2022
1 parent 58e442f commit 58e0e79
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion internal/cmd/inspect_module_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/serve_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 58e0e79

Please sign in to comment.