mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Fix issue with exit code in non-tty mode.
Docker-DCO-1.1-Signed-off-by: Guillaume J. Charmes <guillaume.charmes@docker.com> (github: creack)
This commit is contained in:
parent
62c4563987
commit
fd38de2818
1 changed files with 12 additions and 3 deletions
|
@ -2168,11 +2168,20 @@ func (cli *DockerCli) CmdRun(args ...string) error {
|
|||
return err
|
||||
}
|
||||
} else {
|
||||
if !config.Tty {
|
||||
// In non-tty mode, we can't dettach, so we know we need to wait.
|
||||
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 {
|
||||
return &utils.StatusError{StatusCode: status}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue