| 125 | } |
| 126 | |
| 127 | func (e *Executor) Run(log termlog.Stream, bufferr bool) (error, *ExecState) { |
| 128 | if e.cmd != nil { |
| 129 | return fmt.Errorf("already running"), nil |
| 130 | } |
| 131 | cmd, buff, wg, err := e.start(log, bufferr) |
| 132 | if err != nil { |
| 133 | return err, nil |
| 134 | } |
| 135 | |
| 136 | // Order is important here. We MUST wait for the readers to exit before we wait |
| 137 | // on the command itself. |
| 138 | wg.Wait() |
| 139 | |
| 140 | eret := cmd.Wait() |
| 141 | estate := &ExecState{ |
| 142 | Error: eret, |
| 143 | ErrOutput: buff.String(), |
| 144 | ProcState: cmd.ProcessState.String(), |
| 145 | } |
| 146 | e.reset() |
| 147 | return nil, estate |
| 148 | } |
| 149 | |
| 150 | func (e *Executor) Signal(sig os.Signal) error { |
| 151 | e.Lock() |