mirror of https://github.com/containers/podman.git
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
This commit is contained in:
parent
299f471d1f
commit
35b7a875fd
|
@ -172,6 +172,10 @@ func runCmd(c *cli.Context) error {
|
||||||
if c.IsSet("attach") || c.IsSet("a") {
|
if c.IsSet("attach") || c.IsSet("a") {
|
||||||
outputStream = nil
|
outputStream = nil
|
||||||
errorStream = nil
|
errorStream = nil
|
||||||
|
if !c.Bool("interactive") {
|
||||||
|
inputStream = nil
|
||||||
|
}
|
||||||
|
|
||||||
inputStream = nil
|
inputStream = nil
|
||||||
|
|
||||||
attachTo := c.StringSlice("attach")
|
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)
|
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 {
|
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
|
// This means the command did not exist
|
||||||
exitCode = 127
|
exitCode = 127
|
||||||
|
@ -203,7 +201,7 @@ func runCmd(c *cli.Context) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if ecode, err := ctr.ExitCode(); err != nil {
|
if ecode, err := ctr.Wait(); err != nil {
|
||||||
if errors.Cause(err) == libpod.ErrNoSuchCtr {
|
if errors.Cause(err) == libpod.ErrNoSuchCtr {
|
||||||
// The container may have been removed
|
// The container may have been removed
|
||||||
// Go looking for an exit file
|
// Go looking for an exit file
|
||||||
|
@ -213,8 +211,6 @@ func runCmd(c *cli.Context) error {
|
||||||
} else {
|
} else {
|
||||||
exitCode = ctrExitCode
|
exitCode = ctrExitCode
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
logrus.Errorf("Unable to get exit code of container %s: %q", ctr.ID(), err)
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
exitCode = int(ecode)
|
exitCode = int(ecode)
|
||||||
|
|
|
@ -114,7 +114,7 @@ func startCmd(c *cli.Context) error {
|
||||||
return errors.Wrapf(err, "unable to start container %s", ctr.ID())
|
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)
|
logrus.Errorf("unable to get exit code of container %s: %q", ctr.ID(), err)
|
||||||
} else {
|
} else {
|
||||||
exitCode = int(ecode)
|
exitCode = int(ecode)
|
||||||
|
|
Loading…
Reference in New Issue