From d7f9781bd6cef1373227585bb3b71f557b818822 Mon Sep 17 00:00:00 2001 From: haircommander Date: Tue, 5 Jun 2018 14:21:41 -0400 Subject: Propegate exit code on Exec calls and integrated test Signed-off-by: haircommander Closes: #904 Approved by: rhatdan --- cmd/podman/main.go | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'cmd') diff --git a/cmd/podman/main.go b/cmd/podman/main.go index d4c437706..8edecffb3 100644 --- a/cmd/podman/main.go +++ b/cmd/podman/main.go @@ -3,7 +3,9 @@ package main import ( "fmt" "os" + "os/exec" "runtime/pprof" + "syscall" "github.com/containers/storage/pkg/reexec" "github.com/pkg/errors" @@ -175,6 +177,12 @@ func main() { if debug { logrus.Errorf(err.Error()) } 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()) } } else { -- cgit v1.2.3-54-g00ecf