Merge pull request #552 from hqhq/defer_f_close

Close shim file when cmd.Start fail
This commit is contained in:
Michael Crosby 2017-02-21 11:25:28 -08:00 committed by GitHub
commit 23d3818060
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)