Skip to content

Commit

Permalink
catch and report start cmd failure rather than panicing (#676)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
istyf authored Dec 16, 2024
1 parent e0851cb commit 8fae31c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
8 changes: 7 additions & 1 deletion runner/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
5 changes: 4 additions & 1 deletion runner/util_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit 8fae31c

Please sign in to comment.