beam/examples/beamsh: 'exec' can communicate with its child via beam.

Docker-DCO-1.1-Signed-off-by: Solomon Hykes <solomon@docker.com> (github: shykes)
This commit is contained in:
Solomon Hykes 2014-04-02 21:58:47 -07:00
parent 9598cba7c0
commit 1794406033
4 changed files with 154 additions and 14 deletions

View file

@ -24,6 +24,11 @@ type SendCloser interface {
Close() error
}
type ReceiveSender interface {
Receiver
Sender
}
func SendPipe(dst Sender, data []byte) (*os.File, error) {
r, w, err := os.Pipe()
if err != nil {
@ -111,3 +116,20 @@ func MsgDesc(payload []byte, attachment *os.File) string {
}
return fmt.Sprintf("'%s'[%s]", payload, filedesc)
}
type devnull struct{}
func Devnull() ReceiveSender {
return devnull{}
}
func (d devnull) Send(p []byte, a *os.File) error {
if a != nil {
a.Close()
}
return nil
}
func (d devnull) Receive() ([]byte, *os.File, error) {
return nil, nil, io.EOF
}