From 3aafd651360d2d930ef76f8c7819e3ac8334947e Mon Sep 17 00:00:00 2001 From: Chris Olszewski Date: Tue, 21 Mar 2023 13:15:50 -0700 Subject: [PATCH] fix(signal handling for child process) --- cli/internal/run/real_run.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/cli/internal/run/real_run.go b/cli/internal/run/real_run.go index 9e2507f5e2fdb..ed9262e2005f5 100644 --- a/cli/internal/run/real_run.go +++ b/cli/internal/run/real_run.go @@ -133,8 +133,15 @@ func RealRun( for _, err := range errs { if errors.As(err, &exitCodeErr) { - if exitCodeErr.ExitCode > exitCode { - exitCode = exitCodeErr.ExitCode + // If a process gets killed via a signal, Go reports it's exit code as -1. + // We take the absolute value of the exit code so we don't select '0' as + // the greatest exit code. + childExit := exitCodeErr.ExitCode + if childExit < 0 { + childExit = -childExit + } + if childExit > exitCode { + exitCode = childExit } } else if exitCode == 0 { // We hit some error, it shouldn't be exit code 0