From 35b7a875fd9747a6f322e12f358aeacea778eae5 Mon Sep 17 00:00:00 2001 From: Daniel J Walsh Date: Thu, 12 Jul 2018 17:10:50 -0400 Subject: 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 Closes: #1086 Approved by: baude --- cmd/podman/run.go | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'cmd/podman/run.go') 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) -- cgit v1.2.3-54-g00ecf