Prevent a panic when container fails to start

This occurs when the container was requested to be started in detached
mode and without a tty.

Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
This commit is contained in:
Kenfe-Mickael Laventure 2016-02-16 15:17:54 -08:00
parent 533ee4d688
commit b011f80451
1 changed files with 6 additions and 2 deletions

View File

@ -311,7 +311,9 @@ func runProcess(container libcontainer.Container, config *specs.Process, listenF
defer handler.Close() defer handler.Close()
if err := container.Start(process); err != nil { if err := container.Start(process); err != nil {
tty.Close() if tty != nil {
tty.Close()
}
return -1, err return -1, err
} }
@ -319,7 +321,9 @@ func runProcess(container libcontainer.Container, config *specs.Process, listenF
if err := createPidFile(pidFile, process); err != nil { if err := createPidFile(pidFile, process); err != nil {
process.Signal(syscall.SIGKILL) process.Signal(syscall.SIGKILL)
process.Wait() process.Wait()
tty.Close() if tty != nil {
tty.Close()
}
return -1, err return -1, err
} }
} }