summaryrefslogtreecommitdiff
path: root/cmd/podman/exec.go
diff options
context:
space:
mode:
authorDaniel J Walsh <dwalsh@redhat.com>2019-06-12 05:13:26 -0400
committerDaniel J Walsh <dwalsh@redhat.com>2019-06-12 05:15:58 -0400
commit3bbb692d807277da991a96b336bf88a84b35964d (patch)
treebc04179f6e3db8d097106eaceda199ee33fb6e1e /cmd/podman/exec.go
parentd4681fafe55340043fa421ae31b98681dd6902c4 (diff)
downloadpodman-3bbb692d807277da991a96b336bf88a84b35964d.tar.gz
podman-3bbb692d807277da991a96b336bf88a84b35964d.tar.bz2
podman-3bbb692d807277da991a96b336bf88a84b35964d.zip
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 <dwalsh@redhat.com>
Diffstat (limited to 'cmd/podman/exec.go')
-rw-r--r--cmd/podman/exec.go7
1 files changed, 6 insertions, 1 deletions
diff --git a/cmd/podman/exec.go b/cmd/podman/exec.go
index deff44a92..0684da842 100644
--- a/cmd/podman/exec.go
+++ b/cmd/podman/exec.go
@@ -125,5 +125,10 @@ func execCmd(c *cliconfig.ExecValues) error {
streams.AttachError = true
streams.AttachInput = true
- return ctr.Exec(c.Tty, c.Privileged, envs, cmd, c.User, c.Workdir, streams, c.PreserveFDs)
+ err = ctr.Exec(c.Tty, c.Privileged, envs, cmd, c.User, c.Workdir, streams, c.PreserveFDs)
+ if errors.Cause(err) == libpod.ErrCtrStateInvalid {
+ exitCode = 126
+ }
+
+ return err
}