diff options
Diffstat (limited to 'src/nvim/os/shell.c')
| -rw-r--r-- | src/nvim/os/shell.c | 31 | 
1 files changed, 10 insertions, 21 deletions
diff --git a/src/nvim/os/shell.c b/src/nvim/os/shell.c index 32e9a70e57..e32c6e05d2 100644 --- a/src/nvim/os/shell.c +++ b/src/nvim/os/shell.c @@ -207,16 +207,12 @@ static int do_os_system(char **argv,    char prog[MAXPATHL];    xstrlcpy(prog, argv[0], MAXPATHL); -  Stream in, out, err;    LibuvProcess uvproc = libuv_process_init(&main_loop, &buf);    Process *proc = &uvproc.process;    MultiQueue *events = multiqueue_new_child(main_loop.events);    proc->events = events;    proc->argv = argv; -  proc->in = input != NULL ? &in : NULL; -  proc->out = &out; -  proc->err = &err; -  int status = process_spawn(proc); +  int status = process_spawn(proc, input != NULL, true, true);    if (status) {      loop_poll_events(&main_loop, 0);      // Failed, probably 'shell' is not executable. @@ -231,32 +227,29 @@ static int do_os_system(char **argv,      return -1;    } -  // We want to deal with stream events as fast a possible while queueing -  // process events, so reset everything to NULL. It prevents closing the +  // Note: unlike process events, stream events are not queued, as we want to +  // deal with stream events as fast a possible.  It prevents closing the    // streams while there's still data in the OS buffer (due to the process    // exiting before all data is read).    if (input != NULL) { -    proc->in->events = NULL; -    wstream_init(proc->in, 0); +    wstream_init(&proc->in, 0);    } -  proc->out->events = NULL; -  rstream_init(proc->out, 0); -  rstream_start(proc->out, data_cb, &buf); -  proc->err->events = NULL; -  rstream_init(proc->err, 0); -  rstream_start(proc->err, data_cb, &buf); +  rstream_init(&proc->out, 0); +  rstream_start(&proc->out, data_cb, &buf); +  rstream_init(&proc->err, 0); +  rstream_start(&proc->err, data_cb, &buf);    // write the input, if any    if (input) {      WBuffer *input_buffer = wstream_new_buffer((char *) input, len, 1, NULL); -    if (!wstream_write(&in, input_buffer)) { +    if (!wstream_write(&proc->in, input_buffer)) {        // couldn't write, stop the process and tell the user about it        process_stop(proc);        return -1;      }      // close the input stream after everything is written -    wstream_set_write_cb(&in, shell_write_cb, NULL); +    wstream_set_write_cb(&proc->in, shell_write_cb, NULL);    }    // Invoke busy_start here so LOOP_PROCESS_EVENTS_UNTIL will not change the @@ -684,10 +677,6 @@ static void shell_write_cb(Stream *stream, void *data, int status)      msg_schedule_emsgf(_("E5677: Error writing input to shell-command: %s"),                         uv_err_name(status));    } -  if (stream->closed) {  // Process may have exited before this write. -    WLOG("stream was already closed"); -    return; -  }    stream_close(stream, NULL, NULL);  }  | 
