aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2024-02-26 09:47:49 +0800
committerGitHub <noreply@github.com>2024-02-26 09:47:49 +0800
commit268066e01400f55b0c38716f0d6ee3dece10c43e (patch)
tree42443f64d3d89dadde0c9808d5ba8b22c256db29 /src
parent185752614d1a4906c8f218e4c24c3b52bbe6560e (diff)
downloadrneovim-268066e01400f55b0c38716f0d6ee3dece10c43e.tar.gz
rneovim-268066e01400f55b0c38716f0d6ee3dece10c43e.tar.bz2
rneovim-268066e01400f55b0c38716f0d6ee3dece10c43e.zip
fix(process): start pty process eof timer on main thread (#27625)
Diffstat (limited to 'src')
-rw-r--r--src/nvim/os/pty_process_win.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/nvim/os/pty_process_win.c b/src/nvim/os/pty_process_win.c
index 06ffb5694c..fdc06f9804 100644
--- a/src/nvim/os/pty_process_win.c
+++ b/src/nvim/os/pty_process_win.c
@@ -23,6 +23,17 @@ static void CALLBACK pty_process_finish1(void *context, BOOLEAN unused)
Process *proc = (Process *)ptyproc;
os_conpty_free(ptyproc->conpty);
+ // NB: pty_process_finish1() is called on a separate thread,
+ // but the timer only works properly if it's started by the main thread.
+ loop_schedule_fast(proc->loop, event_create(start_wait_eof_timer, ptyproc));
+}
+
+static void start_wait_eof_timer(void **argv)
+ FUNC_ATTR_NONNULL_ALL
+{
+ PtyProcess *ptyproc = (PtyProcess *)argv[0];
+ Process *proc = (Process *)ptyproc;
+
uv_timer_init(&proc->loop->uv, &ptyproc->wait_eof_timer);
ptyproc->wait_eof_timer.data = (void *)ptyproc;
uv_timer_start(&ptyproc->wait_eof_timer, wait_eof_timer_cb, 200, 200);