mirror of
https://github.com/neovim/neovim.git
synced 2024-12-23 20:55:18 -07:00
Merge #4798 'process.c: Fix block in teardown'
This commit is contained in:
commit
7fa1baf44e
@ -116,23 +116,20 @@ void process_teardown(Loop *loop) FUNC_ATTR_NONNULL_ALL
|
||||
process_is_tearing_down = true;
|
||||
kl_iter(WatcherPtr, loop->children, current) {
|
||||
Process *proc = (*current)->data;
|
||||
if (proc->detach) {
|
||||
if (proc->detach || proc->type == kProcessTypePty) {
|
||||
// Close handles to process without killing it.
|
||||
CREATE_EVENT(loop->events, process_close_handles, 1, proc);
|
||||
} else {
|
||||
if (proc->type == kProcessTypeUv) {
|
||||
uv_kill(proc->pid, SIGTERM);
|
||||
proc->term_sent = true;
|
||||
process_stop(proc);
|
||||
} else { // kProcessTypePty
|
||||
process_close_streams(proc);
|
||||
pty_process_close_master((PtyProcess *)proc);
|
||||
}
|
||||
uv_kill(proc->pid, SIGTERM);
|
||||
proc->term_sent = true;
|
||||
process_stop(proc);
|
||||
}
|
||||
}
|
||||
|
||||
// Wait until all children exit
|
||||
LOOP_PROCESS_EVENTS_UNTIL(loop, loop->events, -1, kl_empty(loop->children));
|
||||
// Wait until all children exit and all close events are processed.
|
||||
LOOP_PROCESS_EVENTS_UNTIL(
|
||||
loop, loop->events, -1,
|
||||
kl_empty(loop->children) && queue_empty(loop->events));
|
||||
pty_process_teardown(loop);
|
||||
}
|
||||
|
||||
@ -315,8 +312,10 @@ static void decref(Process *proc)
|
||||
static void process_close(Process *proc)
|
||||
FUNC_ATTR_NONNULL_ARG(1)
|
||||
{
|
||||
if (process_is_tearing_down && proc->detach && proc->closed) {
|
||||
// If a detached process dies while tearing down it might get closed twice.
|
||||
if (process_is_tearing_down && (proc->detach || proc->type == kProcessTypePty)
|
||||
&& proc->closed) {
|
||||
// If a detached/pty process dies while tearing down it might get closed
|
||||
// twice.
|
||||
return;
|
||||
}
|
||||
assert(!proc->closed);
|
||||
|
Loading…
Reference in New Issue
Block a user