[vim/vim] Unable to detach GUI from terminal with SIGTSTP (Ctrl+Z) (Issue #9570)

22 views
Skip to first unread message

Andrew Maltsev

unread,
Jan 19, 2022, 10:51:33 PM1/19/22
to vim/vim, Subscribed

Steps to reproduce

  1. Run "gvim" or "vim -g" - new window with GUI opens
  2. Press Ctrl+Z in linux terminal or send TSTP by other means
  3. Nothing happens

Expected behaviour

Expecting to suspect GUI and be able to then "bg" or "fg" it.

Version of Vim

8.2.4068

Environment

Linux, Gnome, Gnome terminal, starting a GUI vim.

Logs and stack traces

This worked fine before TSTP handling done recently with https://github.com/vim/vim/commit/ab16ad33ba10dd12ff6660fa57b88f1a30ddd8ba

The pattern of suspending GUI vim is very useful when opening vim from a Linux terminal. Making it always fork is inconvenient in many other situations where waiting for editing to finish is expected. I can sort of understand the desire to handle TSTP in terminal mode, but in GUI suspending is working perfectly fine.

This patch works for me:


--- os_unix.c.orig	2022-01-19 18:59:39.050691542 -0800
+++ os_unix.c	2022-01-19 19:32:58.413457141 -0800
@@ -1377,7 +1377,12 @@
 
 #ifdef SIGTSTP
     // See mch_init() for the conditions under which we ignore SIGTSTP.
-    signal(SIGTSTP, ignore_sigtstp ? SIG_IGN : (RETSIGTYPE (*)())sig_tstp);
+    //
+    // In GUI default TSTP processing is OK.
+    // Checking both gui.in_use and gui.starting because gui.in_use is not
+    // set at this point (set after menus are displayed), but gui.starting
+    // is set.
+    signal(SIGTSTP, ignore_sigtstp ? SIG_IGN : (gui.in_use || gui.starting ? SIG_DFL : (RETSIGTYPE (*)())sig_tstp));
 #endif
 #if defined(SIGCONT)
     signal(SIGCONT, sigcont_handler);


Reply to this email directly, view it on GitHub.
Triage notifications on the go with GitHub Mobile for iOS or Android.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/9570@github.com>

lacygoill

unread,
Jan 23, 2022, 1:09:38 PM1/23/22
to vim/vim, Subscribed

This patch works for me:

I can confirm that your patch fixes the issue:

--- vim82/src/os_unix.c	2022-01-19 18:59:39.050691542 -0800
+++ vim82p/src/os_unix.c	2022-01-19 20:04:11.515327287 -0800
@@ -1377,8 +1377,17 @@
 
 #ifdef SIGTSTP
     // See mch_init() for the conditions under which we ignore SIGTSTP.
+    //
+    // In GUI default TSTP processing is OK.
+    // Checking both gui.in_use and gui.starting because gui.in_use is not
+    // set at this point (set after menus are displayed), but gui.starting
+    // is set.
+#if defined(FEAT_GUI)
+    signal(SIGTSTP, ignore_sigtstp ? SIG_IGN : (gui.in_use || gui.starting ? SIG_DFL : (RETSIGTYPE (*)())sig_tstp));
+#else
     signal(SIGTSTP, ignore_sigtstp ? SIG_IGN : (RETSIGTYPE (*)())sig_tstp);
 #endif
+#endif
 #if defined(SIGCONT)
     signal(SIGCONT, sigcont_handler);
 #endif

Thank you for your contribution.


I ran all the tests and most of them still passed:

-------------------------------
Executed:  4790 Tests
 Skipped:    63 Tests
  Failed:     0 Tests

However, among the ones which were skipped, a few contain the word "GUI". I don't know how to make Vim run the tests for the GUI.

@dbivolaru What is your opinion on the patch?


Reply to this email directly, view it on GitHub.
Triage notifications on the go with GitHub Mobile for iOS or Android.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/9570/1019537570@github.com>

lacygoill

unread,
Jan 23, 2022, 1:18:01 PM1/23/22
to vim/vim, Subscribed

Run "gvim" or "vim -g" - new window with GUI opens

BTW, you forgot to pass the -f or --nofork argument to the vim command:

$ vim -g --nofork
         ^------^

Without, Vim forks a new process, and we cannot reproduce the issue.


Reply to this email directly, view it on GitHub.
Triage notifications on the go with GitHub Mobile for iOS or Android.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/9570/1019539086@github.com>

Bram Moolenaar

unread,
Jan 24, 2022, 7:21:33 AM1/24/22
to vim/vim, Subscribed

Closed #9570 via 8e4af85.


Reply to this email directly, view it on GitHub.
Triage notifications on the go with GitHub Mobile for iOS or Android.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issue/9570/issue_event/5942029210@github.com>

Reply all
Reply to author
Forward
0 new messages