Mercurial > vim
diff src/os_unix.c @ 20800:e76b83c07bd8 v8.2.0952
patch 8.2.0952: no simple way to interrupt Vim
Commit: https://github.com/vim/vim/commit/be5ee8686a50acf07b823bd293f9c765e533d213
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed Jun 10 20:56:58 2020 +0200
patch 8.2.0952: no simple way to interrupt Vim
Problem: No simple way to interrupt Vim.
Solution: Add the SigUSR1 autocommand, triggered by SIGUSR1. (Jacob Hayes,
closes #1718)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Wed, 10 Jun 2020 21:00:04 +0200 |
parents | 503886f64d5f |
children | ce4c58bc5e9e |
line wrap: on
line diff
--- a/src/os_unix.c +++ b/src/os_unix.c @@ -164,6 +164,9 @@ static RETSIGTYPE sig_winch SIGPROTOARG; #if defined(SIGINT) static RETSIGTYPE catch_sigint SIGPROTOARG; #endif +#if defined(SIGUSR1) +static RETSIGTYPE catch_sigusr1 SIGPROTOARG; +#endif #if defined(SIGPWR) static RETSIGTYPE catch_sigpwr SIGPROTOARG; #endif @@ -297,7 +300,7 @@ static struct signalinfo {SIGXFSZ, "XFSZ", TRUE}, #endif #ifdef SIGUSR1 - {SIGUSR1, "USR1", TRUE}, + {SIGUSR1, "USR1", FALSE}, #endif #if defined(SIGUSR2) && !defined(FEAT_SYSMOUSE) // Used for sysmouse handling @@ -837,6 +840,17 @@ catch_sigint SIGDEFARG(sigarg) } #endif +#if defined(SIGUSR1) + static RETSIGTYPE +catch_sigusr1 SIGDEFARG(sigarg) +{ + // this is not required on all systems, but it doesn't hurt anybody + signal(SIGUSR1, (RETSIGTYPE (*)())catch_sigusr1); + got_sigusr1 = TRUE; + SIGRETURN; +} +#endif + #if defined(SIGPWR) static RETSIGTYPE catch_sigpwr SIGDEFARG(sigarg) @@ -1323,10 +1337,10 @@ set_signals(void) #if defined(SIGCONT) signal(SIGCONT, sigcont_handler); #endif +#ifdef SIGPIPE /* * We want to ignore breaking of PIPEs. */ -#ifdef SIGPIPE signal(SIGPIPE, SIG_IGN); #endif @@ -1334,6 +1348,13 @@ set_signals(void) catch_int_signal(); #endif +#ifdef SIGUSR1 + /* + * Call user's handler on SIGUSR1 + */ + signal(SIGUSR1, (RETSIGTYPE (*)())catch_sigusr1); +#endif + /* * Ignore alarm signals (Perl's alarm() generates it). */ @@ -1341,11 +1362,11 @@ set_signals(void) signal(SIGALRM, SIG_IGN); #endif +#ifdef SIGPWR /* * Catch SIGPWR (power failure?) to preserve the swap files, so that no * work will be lost. */ -#ifdef SIGPWR signal(SIGPWR, (RETSIGTYPE (*)())catch_sigpwr); #endif