Close shim file when cmd.Start fail

Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
This commit is contained in:
Qiang Huang 2017-02-21 08:51:40 -08:00
parent da8f4bb904
commit a717d4dc2d
1 changed files with 3 additions and 3 deletions

View File

@ -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)