コード例 #1
0
ファイル: exec.go プロジェクト: hanjin8307/circuit
// 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
ファイル: x.go プロジェクト: hanjin8307/circuit
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
ファイル: x.go プロジェクト: herokai/circuit
func (x XContainer) Stdin() circuit.X {
	return xio.NewXWriteCloser(x.Container.Stdin())
}
コード例 #4
0
ファイル: x.go プロジェクト: hanjin8307/circuit
func (x XProc) Stdin() circuit.X {
	return xio.NewXWriteCloser(x.Proc.Stdin())
}