mirror of https://github.com/containers/podman.git
Propegate exit code on Exec calls and integrated test
Signed-off-by: haircommander <pehunt@redhat.com> Closes: #904 Approved by: rhatdan
This commit is contained in:
parent
cf7c8295b8
commit
d7f9781bd6
|
|
@ -3,7 +3,9 @@ package main
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
"os/exec"
|
||||||
"runtime/pprof"
|
"runtime/pprof"
|
||||||
|
"syscall"
|
||||||
|
|
||||||
"github.com/containers/storage/pkg/reexec"
|
"github.com/containers/storage/pkg/reexec"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
|
@ -175,6 +177,12 @@ func main() {
|
||||||
if debug {
|
if debug {
|
||||||
logrus.Errorf(err.Error())
|
logrus.Errorf(err.Error())
|
||||||
} else {
|
} else {
|
||||||
|
// Retrieve the exit error from the exec call, if it exists
|
||||||
|
if ee, ok := err.(*exec.ExitError); ok {
|
||||||
|
if status, ok := ee.Sys().(syscall.WaitStatus); ok {
|
||||||
|
exitCode = status.ExitStatus()
|
||||||
|
}
|
||||||
|
}
|
||||||
fmt.Fprintln(os.Stderr, err.Error())
|
fmt.Fprintln(os.Stderr, err.Error())
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -86,5 +86,14 @@ var _ = Describe("Podman exec", func() {
|
||||||
os.Unsetenv("FOO")
|
os.Unsetenv("FOO")
|
||||||
|
|
||||||
})
|
})
|
||||||
|
It("podman exec exit code", func() {
|
||||||
|
setup := podmanTest.RunTopContainer("test1")
|
||||||
|
setup.WaitWithDefaultTimeout()
|
||||||
|
Expect(setup.ExitCode()).To(Equal(0))
|
||||||
|
|
||||||
|
session := podmanTest.Podman([]string{"exec", "test1", "sh", "-c", "exit 100"})
|
||||||
|
session.WaitWithDefaultTimeout()
|
||||||
|
Expect(session.ExitCode()).To(Equal(100))
|
||||||
|
})
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue