Пример #1
0
// Start starts the command and returns cross-interfaces to its standard input, output and error.
func (x *XCmd) Start() (xstdin circuit.X, xstdout, xstderr circuit.X, err error) {
	//
	stdin, err := x.cmd.StdinPipe()
	if err != nil {
		return nil, nil, nil, err
	}
	//
	stdout, err := x.cmd.StdoutPipe()
	if err != nil {
		return nil, nil, nil, err
	}
	//
	stderr, err := x.cmd.StderrPipe()
	if err != nil {
		return nil, nil, nil, err
	}
	//
	if err = x.cmd.Start(); err != nil {
		return nil, nil, nil, err
	}
	defer func() {
		go x.cmd.Wait() // Calling wait is necessary, otherwise child remains zombie
	}()
	return xyio.NewXWriteCloser(stdin), xyio.NewXReadCloser(stdout), xyio.NewXReadCloser(stderr), nil
}
Пример #2
0
func (x XValve) Send() (circuit.X, error) {
	w, err := x.Valve.Send()
	if err != nil {
		return nil, errors.Pack(err)
	}
	return xio.NewXWriteCloser(w), nil
}
Пример #3
0
func (x XContainer) Stdin() circuit.X {
	return xio.NewXWriteCloser(x.Container.Stdin())
}
Пример #4
0
func (x XProc) Stdin() circuit.X {
	return xio.NewXWriteCloser(x.Proc.Stdin())
}