From 8fae31cd27648a5844a74616729315abc0a2ee7b Mon Sep 17 00:00:00 2001 From: Isak Styf Date: Mon, 16 Dec 2024 16:47:13 +0100 Subject: [PATCH] catch and report start cmd failure rather than panicing (#676) * do not report the process as running if it failed to start * change the return values on error to match what the other platforms produce --- runner/engine.go | 8 +++++++- runner/util_linux.go | 5 ++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/runner/engine.go b/runner/engine.go index 7af4ed18..8bc2ade7 100644 --- a/runner/engine.go +++ b/runner/engine.go @@ -538,7 +538,13 @@ func (e *Engine) runBin() error { default: e.procKillWg.Add(1) command := strings.Join(append([]string{e.config.Build.Bin}, e.runArgs...), " ") - cmd, stdout, stderr, _ := e.startCmd(command) + cmd, stdout, stderr, err := e.startCmd(command) + if err != nil { + e.mainLog("failed to start %s, error: %s", e.config.rel(e.config.binPath()), err.Error()) + close(killCh) + continue + } + processExit := make(chan struct{}) e.mainDebug("running process pid %v", cmd.Process.Pid) if e.config.Proxy.Enabled { diff --git a/runner/util_linux.go b/runner/util_linux.go index 658671b3..26061d85 100644 --- a/runner/util_linux.go +++ b/runner/util_linux.go @@ -31,5 +31,8 @@ func (e *Engine) killCmd(cmd *exec.Cmd) (pid int, err error) { func (e *Engine) startCmd(cmd string) (*exec.Cmd, io.ReadCloser, io.ReadCloser, error) { c := exec.Command("/bin/sh", "-c", cmd) f, err := pty.Start(c) - return c, f, f, err + if err != nil { + return nil, nil, nil, err + } + return c, f, f, nil }