diff options
-rw-r--r-- | cmd/podman/exec.go | 9 | ||||
-rw-r--r-- | libpod/container_api.go | 2 |
2 files changed, 9 insertions, 2 deletions
diff --git a/cmd/podman/exec.go b/cmd/podman/exec.go index 073e72e64..9e265b48c 100644 --- a/cmd/podman/exec.go +++ b/cmd/podman/exec.go @@ -109,5 +109,12 @@ func execCmd(c *cli.Context) error { envs = append(envs, fmt.Sprintf("%s=%s", k, v)) } - return ctr.Exec(c.Bool("tty"), c.Bool("privileged"), envs, cmd, c.String("user"), c.String("workdir")) + if err := ctr.Exec(c.Bool("tty"), c.Bool("privileged"), envs, cmd, c.String("user"), c.String("workdir")); err != nil { + if errors.Cause(err) == libpod.ErrCtrStateInvalid { + exitCode = 126 + } + return err + } + + return nil } diff --git a/libpod/container_api.go b/libpod/container_api.go index 4eaf737b0..832801aeb 100644 --- a/libpod/container_api.go +++ b/libpod/container_api.go @@ -285,7 +285,7 @@ func (c *Container) Exec(tty, privileged bool, env, cmd []string, user, workDir // TODO can probably relax this once we track exec sessions if conState != ContainerStateRunning { - return errors.Errorf("cannot exec into container that is not running") + return errors.Wrapf(ErrCtrStateInvalid, "cannot exec into container that is not running") } if privileged || c.config.Privileged { capList = caps.GetAllCapabilities() |