From a717d4dc2dfb865c819bbaadc2cc916b193e54e3 Mon Sep 17 00:00:00 2001 From: Qiang Huang Date: Tue, 21 Feb 2017 08:51:40 -0800 Subject: [PATCH] Close shim file when cmd.Start fail Signed-off-by: Qiang Huang --- linux/shim.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/linux/shim.go b/linux/shim.go index f1ce863..62cb032 100644 --- a/linux/shim.go +++ b/linux/shim.go @@ -30,6 +30,9 @@ func newShim(path string) (shim.ShimClient, error) { if err != nil { return nil, err } + // close our side of the socket, do not close the listener as it will + // remove the socket from disk + defer f.Close() cmd.ExtraFiles = append(cmd.ExtraFiles, f) // make sure the shim can be re-parented to system init // and is cloned in a new mount namespace because the overlay/filesystems @@ -41,9 +44,6 @@ func newShim(path string) (shim.ShimClient, error) { if err := cmd.Start(); err != nil { return nil, errors.Wrapf(err, "failed to start shim") } - // close our side of the socket, do not close the listener as it will - // remove the socket from disk - f.Close() // since we are currently the parent go ahead and make sure we wait on the shim go cmd.Wait() return connectShim(socket)