github.com/mutagen-io/mutagen@v0.18.0-rc1/cmd/mutagen-agent/stream.go (about) 1 package main 2 3 import ( 4 "errors" 5 "io" 6 "os" 7 ) 8 9 // stdioStream is an io.ReadWriteCloser that uses standard input/output. 10 type stdioStream struct { 11 io.Reader 12 io.Writer 13 } 14 15 // newStdioStream creates a new stream that uses standard input/output. 16 func newStdioStream() io.ReadWriteCloser { 17 return &stdioStream{os.Stdin, os.Stdout} 18 } 19 20 // Close implements io.Closer.Close. 21 func (s *stdioStream) Close() error { 22 // HACK: We can't really close standard input/output, because on many 23 // platforms these can't be unblocked on reads and writes, and they'll 24 // actually block the call to Close. In the case of the agent, where we're 25 // just running an endpoint (which will be on the path to termination by the 26 // time this method is invoked), this is fine. 27 return errors.New("closing standard input/output connection not allowed") 28 }