From 321b8424042862bc4578a481dcda38842fcb743c Mon Sep 17 00:00:00 2001 From: rajasec Date: Sun, 14 Feb 2016 18:53:02 +0530 Subject: [PATCH] panic during start of failed detached container Signed-off-by: rajasec Adding nil check before closing tty for restore operation Signed-off-by: rajasec --- restore.go | 8 ++++++-- utils.go | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/restore.go b/restore.go index 067c13d3c..645a61f23 100644 --- a/restore.go +++ b/restore.go @@ -135,14 +135,18 @@ func restoreContainer(context *cli.Context, spec *specs.LinuxSpec, config *confi return -1, err } if err := container.Restore(process, options); err != nil { - tty.Close() + if tty != nil { + tty.Close() + } return -1, err } if pidFile := context.String("pid-file"); pidFile != "" { if err := createPidFile(pidFile, process); err != nil { process.Signal(syscall.SIGKILL) process.Wait() - tty.Close() + if tty != nil { + tty.Close() + } return -1, err } } diff --git a/utils.go b/utils.go index fe52b1bb3..1759cb23c 100644 --- a/utils.go +++ b/utils.go @@ -308,7 +308,9 @@ func runProcess(container libcontainer.Container, config *specs.Process, listenF } if err := container.Start(process); err != nil { - tty.Close() + if tty != nil { + tty.Close() + } return -1, err } @@ -316,7 +318,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 } }