From 1131814ab5d0f0dea38c36683efd4423c3b8630f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rog=C3=A9rio=20Peixoto?= Date: Tue, 4 May 2021 14:50:38 +0100 Subject: [PATCH] fix(sast): race condition remediation --- internal/console/scan.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/internal/console/scan.go b/internal/console/scan.go index eec5003fe0e..22ac636df83 100644 --- a/internal/console/scan.go +++ b/internal/console/scan.go @@ -570,10 +570,12 @@ func printOutput(outputPath, filename string, body interface{}, formats []string func gracefulShutdown() { c := make(chan os.Signal) signal.Notify(c, os.Interrupt, syscall.SIGTERM) - go func() { + showErrors := consoleHelpers.ShowError("errors") + interruptCode := constants.SignalInterruptCode + go func(showErrors bool, interruptCode int) { <-c - if consoleHelpers.ShowError("errors") { - os.Exit(constants.SignalInterruptCode) + if showErrors { + os.Exit(interruptCode) } - }() + }(showErrors, interruptCode) }