diff options
author | Daniel J Walsh <dwalsh@redhat.com> | 2018-07-12 17:10:50 -0400 |
---|---|---|
committer | Atomic Bot <atomic-devel@projectatomic.io> | 2018-07-13 14:14:42 +0000 |
commit | 35b7a875fd9747a6f322e12f358aeacea778eae5 (patch) | |
tree | 71f5e7b9d64c8b324ba6dbe805d9575ffea6520e /cmd | |
parent | 299f471d1f897f173ccbbaa883b420e4c49201c9 (diff) | |
download | podman-35b7a875fd9747a6f322e12f358aeacea778eae5.tar.gz podman-35b7a875fd9747a6f322e12f358aeacea778eae5.tar.bz2 podman-35b7a875fd9747a6f322e12f358aeacea778eae5.zip |
Need to wait for container to exit before completing run/start completes
This fixes a race condition where conmon is still writing the exit
file and the container is exiting.
Also we should not be ignoring the -a stdin flag if the user specifies
--interactive mode.
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Closes: #1086
Approved by: baude
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/podman/run.go | 14 | ||||
-rw-r--r-- | cmd/podman/start.go | 2 |
2 files changed, 6 insertions, 10 deletions
diff --git a/cmd/podman/run.go b/cmd/podman/run.go index 2964605f6..b126c9e73 100644 --- a/cmd/podman/run.go +++ b/cmd/podman/run.go @@ -172,6 +172,10 @@ func runCmd(c *cli.Context) error { if c.IsSet("attach") || c.IsSet("a") { outputStream = nil errorStream = nil + if !c.Bool("interactive") { + inputStream = nil + } + inputStream = nil attachTo := c.StringSlice("attach") @@ -187,13 +191,7 @@ func runCmd(c *cli.Context) error { return errors.Wrapf(libpod.ErrInvalidArg, "invalid stream %q for --attach - must be one of stdin, stdout, or stderr", stream) } } - - // If --interactive is set, restore stdin - if c.Bool("interactive") { - inputStream = os.Stdin - } } - if err := startAttachCtr(ctr, outputStream, errorStream, inputStream, c.String("detach-keys"), c.BoolT("sig-proxy"), true); err != nil { // This means the command did not exist exitCode = 127 @@ -203,7 +201,7 @@ func runCmd(c *cli.Context) error { return err } - if ecode, err := ctr.ExitCode(); err != nil { + if ecode, err := ctr.Wait(); err != nil { if errors.Cause(err) == libpod.ErrNoSuchCtr { // The container may have been removed // Go looking for an exit file @@ -213,8 +211,6 @@ func runCmd(c *cli.Context) error { } else { exitCode = ctrExitCode } - } else { - logrus.Errorf("Unable to get exit code of container %s: %q", ctr.ID(), err) } } else { exitCode = int(ecode) diff --git a/cmd/podman/start.go b/cmd/podman/start.go index e917d9198..3dde306d7 100644 --- a/cmd/podman/start.go +++ b/cmd/podman/start.go @@ -114,7 +114,7 @@ func startCmd(c *cli.Context) error { return errors.Wrapf(err, "unable to start container %s", ctr.ID()) } - if ecode, err := ctr.ExitCode(); err != nil { + if ecode, err := ctr.Wait(); err != nil { logrus.Errorf("unable to get exit code of container %s: %q", ctr.ID(), err) } else { exitCode = int(ecode) |