diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2016-10-12 08:45:30 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-10-12 08:45:30 +0200 |
commit | 0190b9fb92bf81e99db0a4b5d6888b4f7eaadeb0 (patch) | |
tree | 7f5cf775fed6d67a9e263d71e8e7dbd190305216 /src | |
parent | 1dde512498d2fa9f3427861b5d4f894c778f992b (diff) | |
parent | b182f247ecf5d49558aae165ba248e2240d3a5d7 (diff) | |
download | rneovim-0190b9fb92bf81e99db0a4b5d6888b4f7eaadeb0.tar.gz rneovim-0190b9fb92bf81e99db0a4b5d6888b4f7eaadeb0.tar.bz2 rneovim-0190b9fb92bf81e99db0a4b5d6888b4f7eaadeb0.zip |
Merge #5463 from justinmk/te-skip-writes
term_write(): Skip writes if stream was closed.
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/eval.c | 16 | ||||
-rw-r--r-- | src/nvim/terminal.c | 2 |
2 files changed, 12 insertions, 6 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 0b1fd6670e..ac8b675834 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -405,7 +405,7 @@ typedef struct { LibuvProcess uv; PtyProcess pty; } proc; - Stream in, out, err; + Stream in, out, err; // Initialized in common_job_start(). Terminal *term; bool stopped; bool exited; @@ -21739,7 +21739,7 @@ static inline TerminalJobData *common_job_init(char **argv, if (!pty) { proc->err = &data->err; } - proc->cb = on_process_exit; + proc->cb = eval_job_process_exit_cb; proc->events = data->events; proc->detach = detach; proc->cwd = cwd; @@ -21923,7 +21923,7 @@ static void on_job_output(Stream *stream, TerminalJobData *data, RBuffer *buf, rbuffer_consumed(buf, count); } -static void on_process_exit(Process *proc, int status, void *d) +static void eval_job_process_exit_cb(Process *proc, int status, void *d) { TerminalJobData *data = d; if (data->term && !data->exited) { @@ -21947,9 +21947,15 @@ static void on_process_exit(Process *proc, int status, void *d) static void term_write(char *buf, size_t size, void *d) { - TerminalJobData *data = d; + TerminalJobData *job = d; + if (job->in.closed) { + // If the backing stream was closed abruptly, there may be write events + // ahead of the terminal close event. Just ignore the writes. + ILOG("write failed: stream is closed"); + return; + } WBuffer *wbuf = wstream_new_buffer(xmemdup(buf, size), size, 1, xfree); - wstream_write(&data->in, wbuf); + wstream_write(&job->in, wbuf); } static void term_resize(uint16_t width, uint16_t height, void *d) diff --git a/src/nvim/terminal.c b/src/nvim/terminal.c index 8401343d7a..499716a7a8 100644 --- a/src/nvim/terminal.c +++ b/src/nvim/terminal.c @@ -366,10 +366,10 @@ void terminal_resize(Terminal *term, uint16_t width, uint16_t height) void terminal_enter(void) { buf_T *buf = curbuf; + assert(buf->terminal); // Should only be called when curbuf has a terminal. TerminalState state, *s = &state; memset(s, 0, sizeof(TerminalState)); s->term = buf->terminal; - assert(s->term && "should only be called when curbuf has a terminal"); // Ensure the terminal is properly sized. terminal_resize(s->term, 0, 0); |