summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-05-11 20:54:42 +0200
committerBram Moolenaar <Bram@vim.org>2020-05-11 20:54:42 +0200
commit5c3128efe6bc48cbd88da23973db389ad3b8ab63 (patch)
tree6a83b30c6c976e4162b80375d089692e8b162447
parentaacc6afdb8cdeb2558e6942dcd65ca0079bec1ee (diff)
downloadvim-git-5c3128efe6bc48cbd88da23973db389ad3b8ab63.tar.gz
patch 8.2.0737: when shell doesn't support CTRL-Z Vim still handles itv8.2.0737
Problem: When shell doesn't support CTRL-Z Vim still handles it. Solution: Ignore the STOP signal if it was ignored on startup. (Kurtis Rader, closes #5990, closes #6058)
-rw-r--r--src/os_unix.c32
-rw-r--r--src/version.c2
2 files changed, 28 insertions, 6 deletions
diff --git a/src/os_unix.c b/src/os_unix.c
index 596fb0e90..b5ae9f868 100644
--- a/src/os_unix.c
+++ b/src/os_unix.c
@@ -129,6 +129,8 @@ Window x11_window = 0;
Display *x11_display = NULL;
#endif
+static int ignore_sigtstp = FALSE;
+
#ifdef FEAT_TITLE
static int get_x11_title(int);
@@ -1237,6 +1239,9 @@ restore_clipboard(void)
void
mch_suspend(void)
{
+ if (ignore_sigtstp)
+ return;
+
// BeOS does have SIGTSTP, but it doesn't work.
#if defined(SIGTSTP) && !defined(__BEOS__)
in_mch_suspend = TRUE;
@@ -1286,6 +1291,14 @@ mch_init(void)
Rows = 24;
out_flush();
+
+#ifdef SIGTSTP
+ // Check whether we were invoked with SIGTSTP set to be ignored. If it is
+ // that indicates the shell (or program) that launched us does not support
+ // tty job control and thus we should ignore that signal. If invoked as a
+ // restricted editor (e.g., as "rvim") SIGTSTP is always ignored.
+ ignore_sigtstp = restricted || SIG_IGN == signal(SIGTSTP, SIG_ERR);
+#endif
set_signals();
#ifdef MACOS_CONVERT
@@ -1306,17 +1319,13 @@ set_signals(void)
signal(SIGWINCH, (RETSIGTYPE (*)())sig_winch);
#endif
- /*
- * We want the STOP signal to work, to make mch_suspend() work.
- * For "rvim" the STOP signal is ignored.
- */
#ifdef SIGTSTP
- signal(SIGTSTP, restricted ? SIG_IGN : SIG_DFL);
+ // See mch_init() for the conditions under which we ignore SIGTSTP.
+ signal(SIGTSTP, ignore_sigtstp ? SIG_IGN : SIG_DFL);
#endif
#if defined(SIGCONT)
signal(SIGCONT, sigcont_handler);
#endif
-
/*
* We want to ignore breaking of PIPEs.
*/
@@ -1386,6 +1395,7 @@ catch_signals(
int i;
for (i = 0; signal_info[i].sig != -1; i++)
+ {
if (signal_info[i].deadly)
{
#if defined(HAVE_SIGALTSTACK) && defined(HAVE_SIGACTION)
@@ -1420,7 +1430,17 @@ catch_signals(
#endif
}
else if (func_other != SIG_ERR)
+ {
+ // Deal with non-deadly signals.
+#ifdef SIGTSTP
+ signal(signal_info[i].sig,
+ signal_info[i].sig == SIGTSTP && ignore_sigtstp
+ ? SIG_IGN : func_other);
+#else
signal(signal_info[i].sig, func_other);
+#endif
+ }
+ }
}
#ifdef HAVE_SIGPROCMASK
diff --git a/src/version.c b/src/version.c
index 7fcef2848..31d83ce87 100644
--- a/src/version.c
+++ b/src/version.c
@@ -747,6 +747,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 737,
+/**/
736,
/**/
735,