@@ -577,23 +577,28 @@ mch_total_mem(int special UNUSED)
577577}
578578#endif
579579
580+ /*
581+ * "flags": MCH_DELAY_IGNOREINPUT - don't read input
582+ * MCH_DELAY_SETTMODE - use settmode() even for short delays
583+ */
580584 void
581- mch_delay (long msec , int ignoreinput )
585+ mch_delay (long msec , int flags )
582586{
583587 tmode_T old_tmode ;
584588#ifdef FEAT_MZSCHEME
585589 long total = msec ; // remember original value
586590#endif
587591
588- if (ignoreinput )
592+ if (flags & MCH_DELAY_IGNOREINPUT )
589593 {
590594 // Go to cooked mode without echo, to allow SIGINT interrupting us
591595 // here. But we don't want QUIT to kill us (CTRL-\ used in a
592596 // shell may produce SIGQUIT).
593597 // Only do this if sleeping for more than half a second.
594598 in_mch_delay = TRUE;
595599 old_tmode = mch_cur_tmode ;
596- if (mch_cur_tmode == TMODE_RAW && msec > 500 )
600+ if (mch_cur_tmode == TMODE_RAW
601+ && (msec > 500 || (flags & MCH_DELAY_SETTMODE )))
597602 settmode (TMODE_SLEEP );
598603
599604 /*
@@ -636,10 +641,8 @@ mch_delay(long msec, int ignoreinput)
636641
637642 tv .tv_sec = msec / 1000 ;
638643 tv .tv_usec = (msec % 1000 ) * 1000 ;
639- /*
640- * NOTE: Solaris 2.6 has a bug that makes select() hang here. Get
641- * a patch from Sun to fix this. Reported by Gunnar Pedersen.
642- */
644+ // NOTE: Solaris 2.6 has a bug that makes select() hang here. Get
645+ // a patch from Sun to fix this. Reported by Gunnar Pedersen.
643646 select (0 , NULL , NULL , NULL , & tv );
644647 }
645648# endif // HAVE_SELECT
@@ -650,7 +653,7 @@ mch_delay(long msec, int ignoreinput)
650653 while (total > 0 );
651654#endif
652655
653- if (msec > 500 )
656+ if (msec > 500 || ( flags & MCH_DELAY_SETTMODE ) )
654657 settmode (old_tmode );
655658 in_mch_delay = FALSE;
656659 }
@@ -1284,7 +1287,7 @@ mch_suspend(void)
12841287 long wait_time ;
12851288
12861289 for (wait_time = 0 ; !sigcont_received && wait_time <= 3L ; wait_time ++ )
1287- mch_delay (wait_time , FALSE );
1290+ mch_delay (wait_time , 0 );
12881291 }
12891292# endif
12901293 in_mch_suspend = FALSE;
@@ -4170,7 +4173,7 @@ wait4pid(pid_t child, waitstatus *status)
41704173 if (wait_pid == 0 )
41714174 {
41724175 // Wait for 1 to 10 msec before trying again.
4173- mch_delay (delay_msec , TRUE );
4176+ mch_delay (delay_msec , MCH_DELAY_IGNOREINPUT | MCH_DELAY_SETTMODE );
41744177 if (++ delay_msec > 10 )
41754178 delay_msec = 10 ;
41764179 continue ;
@@ -5262,6 +5265,9 @@ mch_call_shell_fork(
52625265 {
52635266 long delay_msec = 1 ;
52645267
5268+ out_str (T_CTE ); // possibly disables modifyOtherKeys, so that
5269+ // the system can recognize CTRL-C
5270+
52655271 /*
52665272 * Similar to the loop above, but only handle X events, no
52675273 * I/O.
@@ -5295,11 +5301,14 @@ mch_call_shell_fork(
52955301 clip_update ();
52965302
52975303 // Wait for 1 to 10 msec. 1 is faster but gives the child
5298- // less time.
5299- mch_delay (delay_msec , TRUE);
5304+ // less time, gradually wait longer.
5305+ mch_delay (delay_msec ,
5306+ MCH_DELAY_IGNOREINPUT | MCH_DELAY_SETTMODE );
53005307 if (++ delay_msec > 10 )
53015308 delay_msec = 10 ;
53025309 }
5310+
5311+ out_str (T_CTI ); // possibly enables modifyOtherKeys again
53035312 }
53045313# endif
53055314
@@ -6710,7 +6719,7 @@ mch_expand_wildcards(
67106719 // When running in the background, give it some time to create the temp
67116720 // file, but don't wait for it to finish.
67126721 if (ampersand )
6713- mch_delay (10L , TRUE );
6722+ mch_delay (10L , MCH_DELAY_IGNOREINPUT );
67146723
67156724 extra_shell_arg = NULL ; // cleanup
67166725 show_shell_mess = TRUE;
0 commit comments