process_windows.go 947 B

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