mirror of
https://github.com/neovim/neovim.git
synced 2025-09-25 04:28:33 +00:00
process.c: Fix a block when in teardown mode
nvim blocking can be tested with "nvim +te +'!xclip' +qa" By closing all handles for a pty process, we unblock the event loop if the process has not terminated yet.
This commit is contained in:
@@ -116,18 +116,13 @@ void process_teardown(Loop *loop) FUNC_ATTR_NONNULL_ALL
|
|||||||
process_is_tearing_down = true;
|
process_is_tearing_down = true;
|
||||||
kl_iter(WatcherPtr, loop->children, current) {
|
kl_iter(WatcherPtr, loop->children, current) {
|
||||||
Process *proc = (*current)->data;
|
Process *proc = (*current)->data;
|
||||||
if (proc->detach) {
|
if (proc->detach || proc->type == kProcessTypePty) {
|
||||||
// Close handles to process without killing it.
|
// Close handles to process without killing it.
|
||||||
CREATE_EVENT(loop->events, process_close_handles, 1, proc);
|
CREATE_EVENT(loop->events, process_close_handles, 1, proc);
|
||||||
} else {
|
} else {
|
||||||
if (proc->type == kProcessTypeUv) {
|
uv_kill(proc->pid, SIGTERM);
|
||||||
uv_kill(proc->pid, SIGTERM);
|
proc->term_sent = true;
|
||||||
proc->term_sent = true;
|
process_stop(proc);
|
||||||
process_stop(proc);
|
|
||||||
} else { // kProcessTypePty
|
|
||||||
process_close_streams(proc);
|
|
||||||
pty_process_close_master((PtyProcess *)proc);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -315,8 +310,10 @@ static void decref(Process *proc)
|
|||||||
static void process_close(Process *proc)
|
static void process_close(Process *proc)
|
||||||
FUNC_ATTR_NONNULL_ARG(1)
|
FUNC_ATTR_NONNULL_ARG(1)
|
||||||
{
|
{
|
||||||
if (process_is_tearing_down && proc->detach && proc->closed) {
|
if (process_is_tearing_down && (proc->detach || proc->type == kProcessTypePty)
|
||||||
// If a detached process dies while tearing down it might get closed twice.
|
&& proc->closed) {
|
||||||
|
// If a detached/pty process dies while tearing down it might get closed
|
||||||
|
// twice.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
assert(!proc->closed);
|
assert(!proc->closed);
|
||||||
|
Reference in New Issue
Block a user