diff options
| author | Andrei Vagin <avagin@google.com> | 2023-06-15 11:47:39 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-06-15 11:47:39 -0700 |
| commit | b27a175519cd5a94f2b1e259f9ceae8a585faf2c (patch) | |
| tree | 55d9f70d2a6df9cfe11247aabdc926579459143b /pkg/ipc | |
| parent | 6d01f20890edf11b99bb54573025b11c1acd2d52 (diff) | |
ipc: handle a case when c.cmd.ProcessState is nil (#3967)
This can happen when c.cmd.Wait returns an error.
Signed-off-by: Andrei Vagin <avagin@google.com>
Diffstat (limited to 'pkg/ipc')
| -rw-r--r-- | pkg/ipc/ipc.go | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/pkg/ipc/ipc.go b/pkg/ipc/ipc.go index 5485fd5dd..f30b0afeb 100644 --- a/pkg/ipc/ipc.go +++ b/pkg/ipc/ipc.go @@ -816,22 +816,27 @@ func (c *command) exec(opts *ExecOpts, progData []byte) (output []byte, hanged b } c.cmd.Process.Kill() output = <-c.readDone - if err := c.wait(); <-hang { + err := c.wait() + if err != nil { + output = append(output, err.Error()...) + output = append(output, '\n') + } + if <-hang { hanged = true - if err != nil { - output = append(output, err.Error()...) - output = append(output, '\n') - } return } if exitStatus == -1 { - exitStatus = osutil.ProcessExitStatus(c.cmd.ProcessState) + if c.cmd.ProcessState == nil { + exitStatus = statusFail + } else { + exitStatus = osutil.ProcessExitStatus(c.cmd.ProcessState) + } } // Ignore all other errors. // Without fork server executor can legitimately exit (program contains exit_group), // with fork server the top process can exit with statusFail if it wants special handling. if exitStatus == statusFail { - err0 = fmt.Errorf("executor %v: exit status %d\n%s", c.pid, exitStatus, output) + err0 = fmt.Errorf("executor %v: exit status %d err %s\n%s", c.pid, exitStatus, err, output) } return } |
