diff --git a/internal/oci/runtime_oci.go b/internal/oci/runtime_oci.go index fcf649062d7..a65b0acf082 100644 --- a/internal/oci/runtime_oci.go +++ b/internal/oci/runtime_oci.go @@ -159,6 +159,9 @@ func (r *runtimeOCI) CreateContainer(c *Container, cgroupParent string) (retErr // Platform specific container setup if err := r.createContainerPlatform(c, cgroupParent, cmd.Process.Pid); err != nil { + if waitErr := cmd.Wait(); waitErr != nil { + return errors.Wrap(err, waitErr.Error()) + } return err } @@ -299,6 +302,9 @@ func (r *runtimeOCI) ExecContainer(ctx context.Context, c *Container, cmd []stri // The read side of the pipe should be closed after the container process has been started. if r != nil { if err := r.Close(); err != nil { + if waitErr := execCmd.Wait(); waitErr != nil { + return errors.Wrap(err, waitErr.Error()) + } return err } } diff --git a/internal/storage/image.go b/internal/storage/image.go index d48e47c4daa..99ebe548e35 100644 --- a/internal/storage/image.go +++ b/internal/storage/image.go @@ -571,6 +571,9 @@ func (svc *imageService) copyImage(systemContext *types.SystemContext, imageName } if err := json.NewEncoder(stdin).Encode(&stdinArguments); err != nil { stdin.Close() + if waitErr := cmd.Wait(); waitErr != nil { + return errors.Wrap(err, waitErr.Error()) + } return errors.Wrap(err, "json encode to pipe failed") } stdin.Close()