@@ -238,6 +238,10 @@ static volatile int deadly_signal = 0; /* The signal we caught */
238238/* volatile because it is used in signal handler deathtrap(). */
239239static volatile int in_mch_delay = FALSE; /* sleeping in mch_delay() */
240240
241+ #if defined(FEAT_JOB_CHANNEL ) && !defined(USE_SYSTEM )
242+ static int dont_check_job_ended = 0 ;
243+ #endif
244+
241245static int curr_tmode = TMODE_COOK ; /* contains current terminal mode */
242246
243247#ifdef USE_XSMP
@@ -4485,7 +4489,9 @@ mch_call_shell(
44854489 catch_signals (SIG_IGN , SIG_ERR );
44864490 catch_int_signal ();
44874491 UNBLOCK_SIGNALS (& curset );
4488-
4492+ # ifdef FEAT_JOB_CHANNEL
4493+ ++ dont_check_job_ended ;
4494+ # endif
44894495 /*
44904496 * For the GUI we redirect stdin, stdout and stderr to our window.
44914497 * This is also used to pipe stdin/stdout to/from the external
@@ -5030,6 +5036,10 @@ mch_call_shell(
50305036 wait4pid (wpid , NULL );
50315037 }
50325038
5039+ # ifdef FEAT_JOB_CHANNEL
5040+ -- dont_check_job_ended ;
5041+ # endif
5042+
50335043 /*
50345044 * Set to raw mode right now, otherwise a CTRL-C after
50355045 * catch_signals() will kill Vim.
@@ -5363,6 +5373,14 @@ mch_detect_ended_job(job_T *job_list)
53635373 pid_t wait_pid = 0 ;
53645374 job_T * job ;
53655375
5376+ # ifndef USE_SYSTEM
5377+ /* Do not do this when waiting for a shell command to finish, we would get
5378+ * the exit value here (and discard it), the exit value obtained there
5379+ * would then be wrong. */
5380+ if (dont_check_job_ended > 0 )
5381+ return NULL ;
5382+ # endif
5383+
53665384# ifdef __NeXT__
53675385 wait_pid = wait4 (-1 , & status , WNOHANG , (struct rusage * )0 );
53685386# else
0 commit comments