diff --git a/chrootarchive/archive_unix.go b/chrootarchive/archive_unix.go index 51a43f6..9b26856 100644 --- a/chrootarchive/archive_unix.go +++ b/chrootarchive/archive_unix.go @@ -46,7 +46,10 @@ func untar() { fatal(err) } // fully consume stdin in case it is zero padded - flush(os.Stdin) + if _, err := flush(os.Stdin); err != nil { + fatal(err) + } + os.Exit(0) } diff --git a/chrootarchive/diff_unix.go b/chrootarchive/diff_unix.go index 4196dd4..a4adb74 100644 --- a/chrootarchive/diff_unix.go +++ b/chrootarchive/diff_unix.go @@ -65,8 +65,10 @@ func applyLayer() { fatal(fmt.Errorf("unable to encode layerSize JSON: %s", err)) } - flush(os.Stdout) - flush(os.Stdin) + if _, err := flush(os.Stdin); err != nil { + fatal(err) + } + os.Exit(0) } diff --git a/chrootarchive/init_unix.go b/chrootarchive/init_unix.go index 49fcacc..4f637f1 100644 --- a/chrootarchive/init_unix.go +++ b/chrootarchive/init_unix.go @@ -23,6 +23,6 @@ func fatal(err error) { // flush consumes all the bytes from the reader discarding // any errors -func flush(r io.Reader) { - io.Copy(ioutil.Discard, r) +func flush(r io.Reader) (bytes int64, err error) { + return io.Copy(ioutil.Discard, r) }