Merge pull request #1165 from crosbymichael/delete-hang

Fix process and task io Wait hang when fails to start
This commit is contained in:
Phil Estes
2017-07-12 14:58:05 -04:00
committed by GitHub
7 changed files with 149 additions and 26 deletions

View File

@@ -45,6 +45,7 @@ func (p *process) Start(ctx context.Context) error {
}
response, err := p.task.client.TaskService().Exec(ctx, request)
if err != nil {
p.io.Close()
return err
}
p.pid = response.Pid
@@ -110,7 +111,10 @@ func (p *process) Resize(ctx context.Context, w, h uint32) error {
}
func (p *process) Delete(ctx context.Context) (uint32, error) {
cerr := p.io.Close()
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,
@@ -118,5 +122,5 @@ func (p *process) Delete(ctx context.Context) (uint32, error) {
if err != nil {
return UnknownExitStatus, err
}
return r.ExitStatus, cerr
return r.ExitStatus, nil
}