diff options
author | Daniel J Walsh <dwalsh@redhat.com> | 2019-09-07 05:47:05 -0400 |
---|---|---|
committer | Daniel J Walsh <dwalsh@redhat.com> | 2019-09-12 16:20:01 -0400 |
commit | 82ac0d8925dbb5aa738f1494ecb002eb6daca992 (patch) | |
tree | fcb1d2961f223806b228e7c930bc134fc9f0f7fd /pkg/util | |
parent | 535111b5d5cfa0d203df77e6d6b0b69eda46bb82 (diff) | |
download | podman-82ac0d8925dbb5aa738f1494ecb002eb6daca992.tar.gz podman-82ac0d8925dbb5aa738f1494ecb002eb6daca992.tar.bz2 podman-82ac0d8925dbb5aa738f1494ecb002eb6daca992.zip |
Podman-remote run should wait for exit code
This change matches what is happening on the podman local side
and should eliminate a race condition.
Also exit commands on the server side should start to return to client.
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Diffstat (limited to 'pkg/util')
-rw-r--r-- | pkg/util/utils.go | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/pkg/util/utils.go b/pkg/util/utils.go index 2261934f0..583bf5d18 100644 --- a/pkg/util/utils.go +++ b/pkg/util/utils.go @@ -377,3 +377,19 @@ func ValidatePullType(pullType string) (PullType, error) { return PullImageMissing, errors.Errorf("invalid pull type %q", pullType) } } + +// ExitCode reads the error message when failing to executing container process +// and then returns 0 if no error, 126 if command does not exist, or 127 for +// all other errors +func ExitCode(err error) int { + if err == nil { + return 0 + } + e := strings.ToLower(err.Error()) + if strings.Contains(e, "file not found") || + strings.Contains(e, "no such file or directory") { + return 127 + } + + return 126 +} |