diff --git a/cmd/ctr/commands/tasks/exec.go b/cmd/ctr/commands/tasks/exec.go index 9c99481de..9c5bce78b 100644 --- a/cmd/ctr/commands/tasks/exec.go +++ b/cmd/ctr/commands/tasks/exec.go @@ -94,7 +94,10 @@ var execCommand = cli.Command{ if err != nil { return err } - defer process.Delete(ctx) + // if detach, we should not call this defer + if !detach { + defer process.Delete(ctx) + } statusC, err := process.Wait(ctx) if err != nil {