]> granicus.if.org Git - vim/commitdiff
patch 8.2.1513: cannot interrupt shell used for filename expansion v8.2.1513
authorBram Moolenaar <Bram@vim.org>
Sun, 23 Aug 2020 12:28:37 +0000 (14:28 +0200)
committerBram Moolenaar <Bram@vim.org>
Sun, 23 Aug 2020 12:28:37 +0000 (14:28 +0200)
Problem:    Cannot interrupt shell used for filename expansion. (Dominique
            PellĂ©)
Solution:   Do set tmode in mch_delay(). (closes #6770)

12 files changed:
src/channel.c
src/if_cscope.c
src/os_amiga.c
src/os_unix.c
src/os_win32.c
src/proto/os_amiga.pro
src/proto/os_unix.pro
src/proto/os_win32.pro
src/term.c
src/ui.c
src/version.c
src/vim.h

index 3e7ec96598f626b89e7d6956d843632aa9d31ce8..0b41133c2d2a2bbe66ea21a9eb630025cc029d81 100644 (file)
@@ -904,7 +904,7 @@ channel_connect(
            *waittime -= elapsed_msec;
            if (waitnow > 0)
            {
-               mch_delay((long)waitnow, TRUE);
+               mch_delay((long)waitnow, MCH_DELAY_IGNOREINPUT);
                ui_breakcheck();
                *waittime -= waitnow;
            }
index 0e6f5ae30f8e6a43eedc6b5bd96678927016fa74..c027c71b482f3d67fcf1059a1ef8361e11e9d577 100644 (file)
@@ -2243,7 +2243,7 @@ cs_release_csp(int i, int freefnpp)
            waitpid_errno = errno;
            if (pid != 0)
                break;  // break unless the process is still running
-           mch_delay(50L, FALSE); // sleep 50 ms
+           mch_delay(50L, 0); // sleep 50 ms
        }
 # endif
        /*
@@ -2278,7 +2278,7 @@ cs_release_csp(int i, int freefnpp)
                        alive = FALSE; // cscope process no longer exists
                        break;
                    }
-                   mch_delay(50L, FALSE); // sleep 50ms
+                   mch_delay(50L, 0); // sleep 50 ms
                }
            }
            if (alive)
index 850c26acdab2e5ce5a00b5508fe423afaaabf0cc..91c13e7d29ced40e91f5371f37630ac8d38a63c5 100644 (file)
@@ -222,10 +222,10 @@ mch_avail_mem(int special)
 
 /*
  * Waits a specified amount of time, or until input arrives if
- * ignoreinput is FALSE.
+ * flags does not have MCH_DELAY_IGNOREINPUT.
  */
     void
-mch_delay(long msec, int ignoreinput)
+mch_delay(long msec, int flags)
 {
 #ifndef LATTICE                // SAS declares void Delay(ULONG)
     void           Delay(long);
@@ -233,7 +233,7 @@ mch_delay(long msec, int ignoreinput)
 
     if (msec > 0)
     {
-       if (ignoreinput)
+       if (flags & MCH_DELAY_IGNOREINPUT)
            Delay(msec / 20L);      // Delay works with 20 msec intervals
        else
            WaitForChar(raw_in, msec * 1000L);
index 0f61367f2a107545dfb7b9f8d35764897900cfb7..73caa1a3e45324e37802ecb6b0d7a5fd5d206a47 100644 (file)
@@ -577,15 +577,19 @@ mch_total_mem(int special UNUSED)
 }
 #endif
 
+/*
+ * "flags": MCH_DELAY_IGNOREINPUT - don't read input
+ *         MCH_DELAY_SETTMODE - use settmode() even for short delays
+ */
     void
-mch_delay(long msec, int ignoreinput)
+mch_delay(long msec, int flags)
 {
     tmode_T    old_tmode;
 #ifdef FEAT_MZSCHEME
     long       total = msec; // remember original value
 #endif
 
-    if (ignoreinput)
+    if (flags & MCH_DELAY_IGNOREINPUT)
     {
        // Go to cooked mode without echo, to allow SIGINT interrupting us
        // here.  But we don't want QUIT to kill us (CTRL-\ used in a
@@ -593,7 +597,8 @@ mch_delay(long msec, int ignoreinput)
        // Only do this if sleeping for more than half a second.
        in_mch_delay = TRUE;
        old_tmode = mch_cur_tmode;
-       if (mch_cur_tmode == TMODE_RAW && msec > 500)
+       if (mch_cur_tmode == TMODE_RAW
+                              && (msec > 500 || (flags & MCH_DELAY_SETTMODE)))
            settmode(TMODE_SLEEP);
 
        /*
@@ -636,10 +641,8 @@ mch_delay(long msec, int ignoreinput)
 
            tv.tv_sec = msec / 1000;
            tv.tv_usec = (msec % 1000) * 1000;
-           /*
-            * NOTE: Solaris 2.6 has a bug that makes select() hang here.  Get
-            * a patch from Sun to fix this.  Reported by Gunnar Pedersen.
-            */
+           // NOTE: Solaris 2.6 has a bug that makes select() hang here.  Get
+           // a patch from Sun to fix this.  Reported by Gunnar Pedersen.
            select(0, NULL, NULL, NULL, &tv);
        }
 #  endif // HAVE_SELECT
@@ -650,7 +653,7 @@ mch_delay(long msec, int ignoreinput)
        while (total > 0);
 #endif
 
-       if (msec > 500)
+       if (msec > 500 || (flags & MCH_DELAY_SETTMODE))
            settmode(old_tmode);
        in_mch_delay = FALSE;
     }
@@ -1284,7 +1287,7 @@ mch_suspend(void)
        long wait_time;
 
        for (wait_time = 0; !sigcont_received && wait_time <= 3L; wait_time++)
-           mch_delay(wait_time, FALSE);
+           mch_delay(wait_time, 0);
     }
 # endif
     in_mch_suspend = FALSE;
@@ -4170,7 +4173,7 @@ wait4pid(pid_t child, waitstatus *status)
        if (wait_pid == 0)
        {
            // Wait for 1 to 10 msec before trying again.
-           mch_delay(delay_msec, TRUE);
+           mch_delay(delay_msec, MCH_DELAY_IGNOREINPUT | MCH_DELAY_SETTMODE);
            if (++delay_msec > 10)
                delay_msec = 10;
            continue;
@@ -5262,6 +5265,9 @@ finished:
            {
                long delay_msec = 1;
 
+               out_str(T_CTE); // possibly disables modifyOtherKeys, so that
+                               // the system can recognize CTRL-C
+
                /*
                 * Similar to the loop above, but only handle X events, no
                 * I/O.
@@ -5295,11 +5301,14 @@ finished:
                    clip_update();
 
                    // Wait for 1 to 10 msec. 1 is faster but gives the child
-                   // less time.
-                   mch_delay(delay_msec, TRUE);
+                   // less time, gradually wait longer.
+                   mch_delay(delay_msec,
+                                  MCH_DELAY_IGNOREINPUT | MCH_DELAY_SETTMODE);
                    if (++delay_msec > 10)
                        delay_msec = 10;
                }
+
+               out_str(T_CTI); // possibly enables modifyOtherKeys again
            }
 # endif
 
@@ -6710,7 +6719,7 @@ mch_expand_wildcards(
     // When running in the background, give it some time to create the temp
     // file, but don't wait for it to finish.
     if (ampersand)
-       mch_delay(10L, TRUE);
+       mch_delay(10L, MCH_DELAY_IGNOREINPUT);
 
     extra_shell_arg = NULL;            // cleanup
     show_shell_mess = TRUE;
index 43ad1026d5d0ef2203438106729f69b881f5ac36..96af44364b1b286ab75182287ae70436f757b8be 100644 (file)
@@ -6739,7 +6739,7 @@ notsgr:
     void
 mch_delay(
     long    msec,
-    int            ignoreinput UNUSED)
+    int            flags UNUSED)
 {
 #if defined(FEAT_GUI_MSWIN) && !defined(VIMDLL)
     Sleep((int)msec);      // never wait for input
@@ -6751,7 +6751,7 @@ mch_delay(
        return;
     }
 # endif
-    if (ignoreinput)
+    if (flags & MCH_DELAY_IGNOREINPUT)
 # ifdef FEAT_MZSCHEME
        if (mzthreads_allowed() && p_mzq > 0 && msec > p_mzq)
        {
index b2ad9c3b556b24a0d2732f597501d2cfddfd0f8c..abebae154fefd4a12d436c63dc8816b231ad700b 100644 (file)
@@ -5,7 +5,7 @@ void mch_write(char_u *p, int len);
 int mch_inchar(char_u *buf, int maxlen, long time, int tb_change_cnt);
 int mch_char_avail(void);
 long_u mch_avail_mem(int special);
-void mch_delay(long msec, int ignoreinput);
+void mch_delay(long msec, int flags);
 void mch_suspend(void);
 void mch_init(void);
 int mch_check_win(int argc, char **argv);
index cb84994429bff77a49ddd30440aa0df3843609a0..ee22b4a4228bb170177ace165624413a11b1f0b8 100644 (file)
@@ -5,7 +5,7 @@ int mch_inchar(char_u *buf, int maxlen, long wtime, int tb_change_cnt);
 int mch_char_avail(void);
 int mch_check_messages(void);
 long_u mch_total_mem(int special);
-void mch_delay(long msec, int ignoreinput);
+void mch_delay(long msec, int flags);
 int mch_stackcheck(char *p);
 void mch_suspend(void);
 void mch_init(void);
index 85c09c0ba17e174839862b4a44be5ed41e38c576..18c81273e1e4618c6fb1b98495fe17dbcf5d50a1 100644 (file)
@@ -53,7 +53,7 @@ int mch_signal_job(job_T *job, char_u *how);
 void mch_clear_job(job_T *job);
 void mch_set_normal_colors(void);
 void mch_write(char_u *s, int len);
-void mch_delay(long msec, int ignoreinput);
+void mch_delay(long msec, int flags);
 int mch_remove(char_u *name);
 void mch_breakcheck(int force);
 long_u mch_total_mem(int special);
index 3648df6d5060cbb3cd4cf16ba0005e9e030d902f..b1a7a66c584622f1fe59297eed1e5acd9ad92a2f 100644 (file)
@@ -3598,7 +3598,7 @@ stoptermcap(void)
            {
 # ifdef UNIX
                // Give the terminal a chance to respond.
-               mch_delay(100L, FALSE);
+               mch_delay(100L, 0);
 # endif
 # ifdef TCIFLUSH
                // Discard data received but not read.
index e473f85259af71e83c55ad4977254926f1ed03c5..fc24a01b4d67157644e1e50b48de9e0b9e9dc18e 100644 (file)
--- a/src/ui.c
+++ b/src/ui.c
@@ -539,7 +539,7 @@ ui_delay(long msec_arg, int ignoreinput)
        gui_wait_for_chars(msec, typebuf.tb_change_cnt);
     else
 #endif
-       mch_delay(msec, ignoreinput);
+       mch_delay(msec, ignoreinput ? MCH_DELAY_IGNOREINPUT : 0);
 }
 
 /*
index 2b996d691455d1d16a85f632a74a522d157d3766..b52d4a8c62a72851fa50c7f031bae1d713a7326d 100644 (file)
@@ -754,6 +754,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1513,
 /**/
     1512,
 /**/
index 2b28948726035f189602e3175107a75ca69a95a0..7bcc488c81becf23b01c8c1f338dae7fa2d72769 100644 (file)
--- a/src/vim.h
+++ b/src/vim.h
@@ -2668,4 +2668,8 @@ long elapsed(DWORD start_tick);
 #define READDIR_SORT_IC                2  // sort ignoring case (strcasecmp)
 #define READDIR_SORT_COLLATE   3  // sort according to collation (strcoll)
 
+// Flags for mch_delay.
+#define MCH_DELAY_IGNOREINPUT  1
+#define MCH_DELAY_SETTMODE     2
+
 #endif // VIM__H