Return exit status from Wait of stopped process
This changes Wait() from returning an error whenever you call wait on a stopped process/task to returning the exit status from the process. This also adds the exit status to the Status() call on a process/task so that a user can Wait(), check status, then cancel the wait to avoid races in event handling. Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
@@ -227,17 +227,20 @@ func processFromContainerd(ctx context.Context, p runtime.Process) (*task.Proces
|
||||
status = task.StatusStopped
|
||||
case runtime.PausedStatus:
|
||||
status = task.StatusPaused
|
||||
case runtime.PausingStatus:
|
||||
status = task.StatusPausing
|
||||
default:
|
||||
log.G(ctx).WithField("status", state.Status).Warn("unknown status")
|
||||
}
|
||||
return &task.Process{
|
||||
ID: p.ID(),
|
||||
Pid: state.Pid,
|
||||
Status: status,
|
||||
Stdin: state.Stdin,
|
||||
Stdout: state.Stdout,
|
||||
Stderr: state.Stderr,
|
||||
Terminal: state.Terminal,
|
||||
ID: p.ID(),
|
||||
Pid: state.Pid,
|
||||
Status: status,
|
||||
Stdin: state.Stdin,
|
||||
Stdout: state.Stdout,
|
||||
Stderr: state.Stderr,
|
||||
Terminal: state.Terminal,
|
||||
ExitStatus: state.ExitStatus,
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user