Skip to content
Myr

Immediately close standard output of the child process

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Fix #3828

authored by Junegunn Choi · committed by Junegunn Choi · parent 7c613d0 · Browse files · 1 file+13 added−4 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+13 added−4 removed

  • other:+13 added−4 removed

1 file+13 added−4 removed

modified:src/reader.go+13 added-4 removed
23 unmodified lines
24 event int3225 finChan chan bool26 mutex sync.Mutex27 exec *exec.Cmd28 execOut io.ReadCloser29 command *string30 killed bool31 wait bool32}3334// NewReader returns new Reader object35func NewReader(pusher func([]byte) bool, eventBox *util.EventBox, executor *util.Executor, delimNil bool, wait bool) *Reader {35 return &Reader{pusher, executor, eventBox, delimNil, int32(EvtReady), make(chan bool, 1), sync.Mutex{}, nil, nil, false, wait}36 return &Reader{pusher, executor, eventBox, delimNil, int32(EvtReady), make(chan bool, 1), sync.Mutex{}, nil, nil, nil, false, wait}37}3839func (r *Reader) startEventPoller() {40 go func() {
38 unmodified lines
79func (r *Reader) terminate() {80 r.mutex.Lock()81 r.killed = true82 if r.exec != nil && r.exec.Process != nil {83 r.execOut.Close()84 util.KillCommand(r.exec)85 } else {86 os.Stdin.Close()87 }
176 unmodified lines
264 r.exec = r.executor.ExecCommand(command, true)265 if environ != nil {266 r.exec.Env = environ267 }268269 var err error266 out, err := r.exec.StdoutPipe()270 r.execOut, err = r.exec.StdoutPipe()271 if err != nil {272 r.exec = nil273 r.mutex.Unlock()274 return false275 }276277 err = r.exec.Start()272 r.mutex.Unlock()278 if err != nil {279 r.exec = nil280 r.mutex.Unlock()281 return false282 }283284 r.mutex.Unlock()276 r.feed(out)285 r.feed(r.execOut)286 return r.exec.Wait() == nil287}