1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Merge pull request #3708 from creack/fix_run_exit_code

Fix issue with exit code in non-tty mode.
This commit is contained in:
Michael Crosby 2014-01-21 18:15:01 -08:00
commit 3cb5bc5ae5

View file

@ -2168,9 +2168,18 @@ func (cli *DockerCli) CmdRun(args ...string) error {
return err return err
} }
} else { } else {
// No Autoremove: Simply retrieve the exit code if !config.Tty {
if _, status, err = getExitCode(cli, runResult.ID); err != nil { // In non-tty mode, we can't dettach, so we know we need to wait.
return err if status, err = waitForExit(cli, runResult.ID); err != nil {
return err
}
} else {
// In TTY mode, there is a race. If the process dies too slowly, the state can be update after the getExitCode call
// and result in a wrong exit code.
// No Autoremove: Simply retrieve the exit code
if _, status, err = getExitCode(cli, runResult.ID); err != nil {
return err
}
} }
} }
if status != 0 { if status != 0 {