Skip to content

Commit

Permalink
Correct exit code 126 and 127
Browse files Browse the repository at this point in the history
The exit codes for 126 and 127 were reversed.  For the record, the exit
codes used are as follows:

* 125 if ‘chroot’ itself fails
* 126 if COMMAND is found but cannot be invoked
* 127 if COMMAND cannot be found

This resolves issue #367

Signed-off-by: baude <bbaude@redhat.com>

Closes: #378
Approved by: baude
  • Loading branch information
baude authored and rh-atomic-bot committed Feb 21, 2018
1 parent 6ce70a3 commit f1f0f37
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions cmd/podman/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ func runCmd(c *cli.Context) error {
logrus.Debug("new container created ", ctr.ID())
if err := ctr.Init(); err != nil {
// This means the command did not exist
exitCode = 126
exitCode = 127
if strings.Index(err.Error(), "permission denied") > -1 {
exitCode = 127
exitCode = 126
}
return err
}
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/run_exit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ var _ = Describe("Podman run exit", func() {
})

It("podman run exit 126", func() {
result := podmanTest.Podman([]string{"run", ALPINE, "foobar"})
result := podmanTest.Podman([]string{"run", ALPINE, "/etc"})
result.WaitWithDefaultTimeout()
Expect(result.ExitCode()).To(Equal(126))
})

It("podman run exit 127", func() {
result := podmanTest.Podman([]string{"run", ALPINE, "/etc"})
result := podmanTest.Podman([]string{"run", ALPINE, "foobar"})
result.WaitWithDefaultTimeout()
Expect(result.ExitCode()).To(Equal(127))
})
Expand Down

0 comments on commit f1f0f37

Please sign in to comment.