neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

commit 0b61bc8982304c3b8afd9f3c310b112227302bc5
parent 3af43cffa028b88022e6bdc78a4e2f5470643219
Author: phanium <91544758+phanen@users.noreply.github.com>
Date:   Wed,  2 Apr 2025 23:12:19 +0800

fix(events): crash on SIGTSTP (Ctrl-Z) #33258

Problem:
Nvim crashes on receive SIGTSTP (Ctrl-Z) since 4dabeff308222307ede8e74a2bd341713a7f7d81.

Solution:
* Don't exit on SIGTSTP (not a deadly signal).
* Avoid SIGTSTP handler in os/signal.c.

Co-authored-by: 27Onion Nebell <zzy20080201@gmail.com>
Diffstat:
Msrc/nvim/os/signal.c | 6+++++-
Msrc/nvim/tui/tui.c | 3++-
2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/nvim/os/signal.c b/src/nvim/os/signal.c @@ -212,10 +212,14 @@ static void on_signal(SignalWatcher *handle, int signum, void *data) // Ignore break; #endif - case SIGTERM: #ifdef SIGTSTP case SIGTSTP: + if (p_awa) { + autowrite_all(); + } + break; #endif + case SIGTERM: #ifdef SIGQUIT case SIGQUIT: #endif diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c @@ -1576,7 +1576,8 @@ void tui_suspend(TUIData *tui) tui_terminal_stop(tui); stream_set_blocking(tui->input.in_fd, true); // normalize stream (#2598) - kill(0, SIGTSTP); + // Avoid os/signal.c SIGTSTP handler. ex_stop calls auto_writeall. #33258 + kill(0, SIGSTOP); tui_terminal_start(tui); tui_terminal_after_startup(tui);