github.com/demonoid81/moby@v0.0.0-20200517203328-62dd8e17c460/libcontainerd/local/process_windows.go (about) 1 package local // import "github.com/demonoid81/moby/libcontainerd/local" 2 3 import ( 4 "io" 5 "sync" 6 7 "github.com/Microsoft/hcsshim" 8 "github.com/demonoid81/moby/pkg/ioutils" 9 ) 10 11 type autoClosingReader struct { 12 io.ReadCloser 13 sync.Once 14 } 15 16 func (r *autoClosingReader) Read(b []byte) (n int, err error) { 17 n, err = r.ReadCloser.Read(b) 18 if err != nil { 19 r.Once.Do(func() { r.ReadCloser.Close() }) 20 } 21 return 22 } 23 24 func createStdInCloser(pipe io.WriteCloser, process hcsshim.Process) io.WriteCloser { 25 return ioutils.NewWriteCloserWrapper(pipe, func() error { 26 if err := pipe.Close(); err != nil { 27 return err 28 } 29 30 err := process.CloseStdin() 31 if err != nil && !hcsshim.IsNotExist(err) && !hcsshim.IsAlreadyClosed(err) { 32 // This error will occur if the compute system is currently shutting down 33 if perr, ok := err.(*hcsshim.ProcessError); ok && perr.Err != hcsshim.ErrVmcomputeOperationInvalidState { 34 return err 35 } 36 } 37 38 return nil 39 }) 40 } 41 42 func (p *process) Cleanup() error { 43 return nil 44 }