From b011f804510023b99ccdb932e41fd39ed529eeaa Mon Sep 17 00:00:00 2001 From: Kenfe-Mickael Laventure Date: Tue, 16 Feb 2016 15:17:54 -0800 Subject: [PATCH] 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 --- utils.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/utils.go b/utils.go index ef6fbba3e..463de9c5b 100644 --- a/utils.go +++ b/utils.go @@ -311,7 +311,9 @@ func runProcess(container libcontainer.Container, config *specs.Process, listenF defer handler.Close() if err := container.Start(process); err != nil { - tty.Close() + if tty != nil { + tty.Close() + } return -1, err } @@ -319,7 +321,9 @@ func runProcess(container libcontainer.Container, config *specs.Process, listenF if err := createPidFile(pidFile, process); err != nil { process.Signal(syscall.SIGKILL) process.Wait() - tty.Close() + if tty != nil { + tty.Close() + } return -1, err } }