aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThiago de Arruda <tpadilha84@gmail.com>2014-10-23 17:00:46 -0300
committerThiago de Arruda <tpadilha84@gmail.com>2014-10-23 21:19:08 -0300
commitf05fead12e380fa63dc99ceb65332569e4e06c43 (patch)
treefad57dec162ec0bdce62ced00175128fd7bfe64a
parent6f5f3faa840a70e9e2b0a532f0f76c9a755421b9 (diff)
downloadrneovim-f05fead12e380fa63dc99ceb65332569e4e06c43.tar.gz
rneovim-f05fead12e380fa63dc99ceb65332569e4e06c43.tar.bz2
rneovim-f05fead12e380fa63dc99ceb65332569e4e06c43.zip
job: Only decrease refcount after `settmode` in `job_wait`
This is required to prevent the scenario explained by @akkartik in #1324
-rw-r--r--src/nvim/os/job.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/src/nvim/os/job.c b/src/nvim/os/job.c
index 947538af4b..caada5616b 100644
--- a/src/nvim/os/job.c
+++ b/src/nvim/os/job.c
@@ -291,7 +291,6 @@ int job_wait(Job *job, int ms) FUNC_ATTR_NONNULL_ALL
// Until...
got_int || // interrupted by the user
job->refcount == 1); // job exited
- job->refcount--;
// we'll assume that a user frantically hitting interrupt doesn't like
// the current job. Signal that it has to be killed.
@@ -302,7 +301,7 @@ int job_wait(Job *job, int ms) FUNC_ATTR_NONNULL_ALL
settmode(old_mode);
- if (!job->refcount) {
+ if (!--job->refcount) {
int status = (int) job->status;
// Manually invoke close_cb to free the job resources
close_cb((uv_handle_t *)&job->proc);