mirror of
https://github.com/neovim/neovim.git
synced 2025-09-30 15:08:35 +00:00
job: Close the process in a queued event handler
Since all reads are queued by the event loop, we must also queue the exit event, or else the process_close function can close the job streams before received data is processed.
This commit is contained in:
@@ -406,6 +406,12 @@ static void close_cb(uv_handle_t *handle)
|
|||||||
job_decref(handle_get_job(handle));
|
job_decref(handle_get_job(handle));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void job_exited(Event event)
|
||||||
|
{
|
||||||
|
Job *job = event.data;
|
||||||
|
process_close(job);
|
||||||
|
}
|
||||||
|
|
||||||
static void chld_handler(uv_signal_t *handle, int signum)
|
static void chld_handler(uv_signal_t *handle, int signum)
|
||||||
{
|
{
|
||||||
int stat = 0;
|
int stat = 0;
|
||||||
@@ -433,7 +439,12 @@ static void chld_handler(uv_signal_t *handle, int signum)
|
|||||||
} else if (WIFSIGNALED(stat)) {
|
} else if (WIFSIGNALED(stat)) {
|
||||||
job->status = WTERMSIG(stat);
|
job->status = WTERMSIG(stat);
|
||||||
}
|
}
|
||||||
|
if (exiting) {
|
||||||
|
// don't enqueue more events when exiting
|
||||||
process_close(job);
|
process_close(job);
|
||||||
|
} else {
|
||||||
|
event_push((Event) {.handler = job_exited, .data = job}, false);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user