Close pipe in chrootarchive.invokeUnpack when cmd.Start()/json.NewEncoder failed.

Signed-off-by: y00316549 <yangshukui@huawei.com>
Upstream-commit: f5f8f008608e579e9164647910ef6f976e91e297
Component: engine
This commit is contained in:
y00316549
2017-11-24 13:41:08 +08:00
parent c7f0d04c5e
commit 52ebdfbe5d

View File

@ -66,10 +66,12 @@ func invokeUnpack(decompressedArchive io.Reader, dest string, options *archive.T
cmd.Stderr = output
if err := cmd.Start(); err != nil {
w.Close()
return fmt.Errorf("Untar error on re-exec cmd: %v", err)
}
//write the options to the pipe for the untar exec to read
if err := json.NewEncoder(w).Encode(options); err != nil {
w.Close()
return fmt.Errorf("Untar json encode to pipe failed: %v", err)
}
w.Close()