vim: backout ab16ad33ba (patch 8.2.3941) which results in an

uninterruptible loop when pressing ^Z

ab16ad33ba
This commit is contained in:
sthen 2022-01-17 17:03:19 +00:00
parent f33db3f7f5
commit 84a492ce9d
6 changed files with 225 additions and 1 deletions

View File

@ -1,4 +1,4 @@
# $OpenBSD: Makefile,v 1.222 2022/01/15 15:40:27 sthen Exp $
# $OpenBSD: Makefile,v 1.223 2022/01/17 17:03:19 sthen Exp $
COMMENT-main= vi clone, many additional features
COMMENT-lang= vi clone, NLS subpackage
@ -8,6 +8,7 @@ V= 8.2.4096
GH_ACCOUNT= vim
GH_PROJECT= vim
GH_TAGNAME= v$V
REVISION= 0
T= ${V:C/\.0+/./}
PKGNAME= vim-$T

View File

@ -0,0 +1,19 @@
$OpenBSD: patch-runtime_doc_autocmd_txt,v 1.1 2022/01/17 17:03:19 sthen Exp $
backout ab16ad33ba "patch 8.2.3941: SIGTSTP is not handled"
causes hangs on ^Z
Index: runtime/doc/autocmd.txt
--- runtime/doc/autocmd.txt.orig
+++ runtime/doc/autocmd.txt
@@ -1279,8 +1279,8 @@ VimResume When the Vim instance is resumed after bei
:autocmd VimResume * checktime
< *VimSuspend*
VimSuspend When the Vim instance is suspended. Only when
- CTRL-Z was typed inside Vim, or when the SIGTSTP
- signal was sent to Vim, but not for SIGSTOP.
+ CTRL-Z was typed inside Vim, not when the
+ SIGSTOP or SIGTSTP signal was sent to Vim.
*WinClosed*
WinClosed After closing a window. The pattern is
matched against the |window-ID|. Both

View File

@ -0,0 +1,25 @@
$OpenBSD: patch-src_ex_docmd_c,v 1.1 2022/01/17 17:03:19 sthen Exp $
backout ab16ad33ba "patch 8.2.3941: SIGTSTP is not handled"
causes hangs on ^Z
Index: src/ex_docmd.c
--- src/ex_docmd.c.orig
+++ src/ex_docmd.c
@@ -109,6 +109,7 @@ static void ex_pedit(exarg_T *eap);
# define ex_pedit ex_ni
#endif
static void ex_hide(exarg_T *eap);
+static void ex_stop(exarg_T *eap);
static void ex_exit(exarg_T *eap);
static void ex_print(exarg_T *eap);
#ifdef FEAT_BYTEOFF
@@ -6206,7 +6207,7 @@ ex_hide(exarg_T *eap UNUSED)
/*
* ":stop" and ":suspend": Suspend Vim.
*/
- void
+ static void
ex_stop(exarg_T *eap)
{
/*

View File

@ -0,0 +1,96 @@
$OpenBSD: patch-src_os_unix_c,v 1.1 2022/01/17 17:03:19 sthen Exp $
backout ab16ad33ba "patch 8.2.3941: SIGTSTP is not handled"
causes hangs on ^Z
Index: src/os_unix.c
--- src/os_unix.c.orig
+++ src/os_unix.c
@@ -157,11 +157,6 @@ static void handle_resize(void);
#if defined(SIGWINCH)
static RETSIGTYPE sig_winch SIGPROTOARG;
#endif
-#if defined(SIGTSTP)
-static RETSIGTYPE sig_tstp SIGPROTOARG;
-// volatile because it is used in signal handler sig_tstp() and sigcont_handler().
-static volatile sig_atomic_t in_mch_suspend = FALSE;
-#endif
#if defined(SIGINT)
static RETSIGTYPE catch_sigint SIGPROTOARG;
#endif
@@ -202,8 +197,6 @@ static int save_patterns(int num_pat, char_u **pat, in
// volatile because it is used in signal handler sig_winch().
static volatile sig_atomic_t do_resize = FALSE;
-// volatile because it is used in signal handler sig_tstp().
-static volatile sig_atomic_t got_tstp = FALSE;
static char_u *extra_shell_arg = NULL;
static int show_shell_mess = TRUE;
// volatile because it is used in signal handler deathtrap().
@@ -858,24 +851,6 @@ sig_winch SIGDEFARG(sigarg)
}
#endif
-#if defined(SIGTSTP)
- static RETSIGTYPE
-sig_tstp SIGDEFARG(sigarg)
-{
- // Second time we get called we actually need to suspend
- if (in_mch_suspend)
- {
- signal(SIGTSTP, ignore_sigtstp ? SIG_IGN : SIG_DFL);
- raise(sigarg);
- }
-
- // this is not required on all systems, but it doesn't hurt anybody
- signal(SIGTSTP, (RETSIGTYPE (*)())sig_tstp);
- got_tstp = TRUE;
- SIGRETURN;
-}
-#endif
-
#if defined(SIGINT)
static RETSIGTYPE
catch_sigint SIGDEFARG(sigarg)
@@ -1183,6 +1158,7 @@ after_sigcont(void)
#if defined(SIGCONT)
static RETSIGTYPE sigcont_handler SIGPROTOARG;
+static volatile sig_atomic_t in_mch_suspend = FALSE;
/*
* With multi-threading, suspending might not work immediately. Catch the
@@ -1377,7 +1353,7 @@ set_signals(void)
#ifdef SIGTSTP
// See mch_init() for the conditions under which we ignore SIGTSTP.
- signal(SIGTSTP, ignore_sigtstp ? SIG_IGN : (RETSIGTYPE (*)())sig_tstp);
+ signal(SIGTSTP, ignore_sigtstp ? SIG_IGN : SIG_DFL);
#endif
#if defined(SIGCONT)
signal(SIGCONT, sigcont_handler);
@@ -6410,15 +6386,6 @@ select_eintr:
# ifdef EINTR
if (ret == -1 && errno == EINTR)
{
- // Check whether the EINTR is caused by SIGTSTP
- if (got_tstp && !in_mch_suspend)
- {
- exarg_T ea;
- ea.forceit = TRUE;
- ex_stop(&ea);
- got_tstp = FALSE;
- }
-
// Check whether window has been resized, EINTR may be caused by
// SIGWINCH.
if (do_resize)
@@ -7209,7 +7176,7 @@ gpm_open(void)
// we are going to suspend or starting an external process
// so we shouldn't have problem with this
# ifdef SIGTSTP
- signal(SIGTSTP, restricted ? SIG_IGN : (RETSIGTYPE (*)())sig_tstp);
+ signal(SIGTSTP, restricted ? SIG_IGN : SIG_DFL);
# endif
return 1; // succeed
}

View File

@ -0,0 +1,16 @@
$OpenBSD: patch-src_proto_ex_docmd_pro,v 1.1 2022/01/17 17:03:19 sthen Exp $
backout ab16ad33ba "patch 8.2.3941: SIGTSTP is not handled"
causes hangs on ^Z
Index: src/proto/ex_docmd.pro
--- src/proto/ex_docmd.pro.orig
+++ src/proto/ex_docmd.pro
@@ -40,7 +40,6 @@ int before_quit_autocmds(win_T *wp, int quit_all, int
void ex_quit(exarg_T *eap);
void tabpage_close(int forceit);
void tabpage_close_other(tabpage_T *tp, int forceit);
-void ex_stop(exarg_T *eap);
void handle_drop(int filec, char_u **filev, int split, void (*callback)(void *), void *cookie);
void handle_any_postponed_drop(void);
void ex_splitview(exarg_T *eap);

View File

@ -0,0 +1,67 @@
$OpenBSD: patch-src_testdir_test_signals_vim,v 1.1 2022/01/17 17:03:19 sthen Exp $
backout ab16ad33ba "patch 8.2.3941: SIGTSTP is not handled"
causes hangs on ^Z
Index: src/testdir/test_signals.vim
--- src/testdir/test_signals.vim.orig
+++ src/testdir/test_signals.vim
@@ -105,58 +105,6 @@ func Test_signal_INT()
call StopVimInTerminal(buf)
endfunc
-" Test signal TSTP. Handler sets got_tstp.
-func Test_signal_TSTP()
- CheckRunVimInTerminal
- if !HasSignal('TSTP')
- throw 'Skipped: TSTP signal not supported'
- endif
-
- " Skip the test when running with valgrind as signal TSTP is not received
- " somehow by Vim when running with valgrind.
- let cmd = GetVimCommand()
- if cmd =~ 'valgrind'
- throw 'Skipped: cannot test signal TSTP with valgrind'
- endif
-
- " If test fails once, it can leave temporary files and trying to rerun
- " the test would then fail again if they are not deleted first.
- call delete('.Xsig_TERM.swp')
- call delete('XsetupAucmd')
- call delete('XautoOut')
- let lines =<< trim END
- au VimSuspend * call writefile(["VimSuspend triggered"], "XautoOut", "as")
- au VimResume * call writefile(["VimResume triggered"], "XautoOut", "as")
- END
- call writefile(lines, 'XsetupAucmd')
-
- let buf = RunVimInTerminal('-S XsetupAucmd Xsig_TERM', {'rows': 6})
- let pid_vim = term_getjob(buf)->job_info().process
-
- call term_sendkeys(buf, ":call setline(1, 'foo')\n")
- call WaitForAssert({-> assert_equal('foo', term_getline(buf, 1))})
-
- call assert_false(filereadable('Xsig_TERM'))
-
- " After TSTP the file is not saved (same function as ^Z)
- exe 'silent !kill -s TSTP ' .. pid_vim
- call WaitForAssert({-> assert_true(filereadable('.Xsig_TERM.swp'))})
-
- " We resume after the suspend
- exe 'silent !kill -s CONT ' .. pid_vim
- exe 'silent !sleep 0.006'
-
- call StopVimInTerminal(buf)
-
- let result = readfile('XautoOut')
- call assert_equal(["VimSuspend triggered", "VimResume triggered"], result)
-
- %bwipe!
- call delete('.Xsig_TERM.swp')
- call delete('XsetupAucmd')
- call delete('XautoOut')
-endfunc
-
" Test a deadly signal.
"
" There are several deadly signals: SISEGV, SIBUS, SIGTERM...