From a19975f96d2ee7efe186d9aa0be42285cfafa3f4 Mon Sep 17 00:00:00 2001 From: Daniel J Walsh Date: Wed, 12 Jun 2019 05:13:26 -0400 Subject: If container is not in correct state podman exec should exit with 126 This way a tool can determine if the container exists or not, but is in the wrong state. Since 126 is documeted as: **_126_** if the **_contained command_** cannot be invoked It makes sense that the container would exit with this state. Signed-off-by: Daniel J Walsh Signed-off-by: Matthew Heon --- cmd/podman/exec.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'cmd') 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 } -- cgit v1.2.3-54-g00ecf