summaryrefslogtreecommitdiff
path: root/src/os_unix.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-06-10 20:56:58 +0200
committerBram Moolenaar <Bram@vim.org>2020-06-10 20:56:58 +0200
commitbe5ee8686a50acf07b823bd293f9c765e533d213 (patch)
treefc5056db66c81eefa83a30afae305b9b027677d8 /src/os_unix.c
parent6ba24d87630b1ec2b8c7ff71550c9e41d143800e (diff)
downloadvim-git-be5ee8686a50acf07b823bd293f9c765e533d213.tar.gz
patch 8.2.0952: no simple way to interrupt Vimv8.2.0952
Problem: No simple way to interrupt Vim. Solution: Add the SigUSR1 autocommand, triggered by SIGUSR1. (Jacob Hayes, closes #1718)
Diffstat (limited to 'src/os_unix.c')
-rw-r--r--src/os_unix.c27
1 files changed, 24 insertions, 3 deletions
diff --git a/src/os_unix.c b/src/os_unix.c
index c6ba2499b..095e3a78e 100644
--- 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