windows: Close IO if process in created state

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
Kenfe-Mickael Laventure 2017-08-22 20:45:22 +00:00 committed by Michael Crosby
parent 1b470c180e
commit fc535efe58
2 changed files with 11 additions and 4 deletions

View File

@ -190,10 +190,6 @@ func (p *process) Delete(ctx context.Context, opts ...ProcessDeleteOpts) (uint32
case Running, Paused, Pausing:
return UnknownExitStatus, errors.Wrapf(errdefs.ErrFailedPrecondition, "process must be stopped before deletion")
}
if p.io != nil {
p.io.Wait()
p.io.Close()
}
r, err := p.task.client.TaskService().DeleteProcess(ctx, &tasks.DeleteProcessRequest{
ContainerID: p.task.id,
ExecID: p.id,
@ -201,6 +197,10 @@ func (p *process) Delete(ctx context.Context, opts ...ProcessDeleteOpts) (uint32
if err != nil {
return UnknownExitStatus, errdefs.FromGRPC(err)
}
if p.io != nil {
p.io.Wait()
p.io.Close()
}
return r.ExitStatus, nil
}

View File

@ -240,6 +240,13 @@ func (t *task) DeleteProcess(ctx context.Context, id string) (*runtime.Exit, err
if err != nil {
return nil, err
}
// If we never started the process close the pipes
if p.Status() == runtime.CreatedStatus {
p.io.Close()
ea = time.Now()
}
t.removeProcess(id)
return &runtime.Exit{
Pid: p.pid,