Check status for stopped processes before wait

Fixes #1054

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
Michael Crosby
2017-07-31 16:09:42 -04:00
parent cd00216fd7
commit 83b27db923
3 changed files with 185 additions and 12 deletions

View File

@@ -13,6 +13,18 @@ import (
specs "github.com/opencontainers/runtime-spec/specs-go"
)
type Process interface {
Pid() uint32
Start(context.Context) error
Delete(context.Context) (uint32, error)
Kill(context.Context, syscall.Signal) error
Wait(context.Context) (uint32, error)
CloseIO(context.Context, ...IOCloserOpts) error
Resize(ctx context.Context, w, h uint32) error
IO() *IO
Status(context.Context) (Status, error)
}
type process struct {
id string
task *task
@@ -63,6 +75,10 @@ func (p *process) Wait(ctx context.Context) (uint32, error) {
if err != nil {
return UnknownExitStatus, err
}
// first check if the task has exited
if status, _ := p.Status(ctx); status == Stopped {
return UnknownExitStatus, errdefs.ErrUnavailable
}
for {
evt, err := eventstream.Recv()
if err != nil {