From 52991d8728c876366cd28f75be29ee579a0a8605 Mon Sep 17 00:00:00 2001 From: Emanuel Krollmann <115734183+Sodastream11@users.noreply.github.com> Date: Mon, 2 Jun 2025 00:23:42 +0200 Subject: [PATCH] fix(windows): don't set window icon on SIGHUP #34260 Problem: When using conhost and pressing the 'x' button to close it while nvim is open, nvim hangs up while trying to reset the window icon, causing a big delay before the terminal actually closes. #34171 Solution: Set the window handle to NULL after receiving SIGHUP so that nvim will not try resetting the icon. --- src/nvim/os/os_win_console.c | 5 +++++ src/nvim/os/signal.c | 9 ++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/nvim/os/os_win_console.c b/src/nvim/os/os_win_console.c index b1bbe60eab..191e07dee3 100644 --- a/src/nvim/os/os_win_console.c +++ b/src/nvim/os/os_win_console.c @@ -29,6 +29,11 @@ int os_open_conin_fd(void) return conin_fd; } +void os_clear_hwnd(void) +{ + hWnd = NULL; +} + void os_replace_stdin_to_conin(void) { close(STDIN_FILENO); diff --git a/src/nvim/os/signal.c b/src/nvim/os/signal.c index b09d11bc51..80c29417a9 100644 --- a/src/nvim/os/signal.c +++ b/src/nvim/os/signal.c @@ -23,6 +23,10 @@ # include "nvim/memline.h" #endif +#ifdef MSWIN +# include "nvim/os/os_win_console.h" +#endif + static SignalWatcher spipe, shup, squit, sterm, susr1, swinch, ststp; #ifdef SIGPWR static SignalWatcher spwr; @@ -218,12 +222,15 @@ static void on_signal(SignalWatcher *handle, int signum, void *data) autowrite_all(); } break; +#endif + case SIGHUP: +#ifdef MSWIN + os_clear_hwnd(); #endif case SIGTERM: #ifdef SIGQUIT case SIGQUIT: #endif - case SIGHUP: if (!rejecting_deadly) { deadly_signal(signum); }