From 268066e01400f55b0c38716f0d6ee3dece10c43e Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 26 Feb 2024 09:47:49 +0800 Subject: fix(process): start pty process eof timer on main thread (#27625) --- src/nvim/os/pty_process_win.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src') 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); -- cgit