@@ -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
@@ -4503,7 +4507,9 @@ mch_call_shell(
45034507 catch_signals (SIG_IGN , SIG_ERR );
45044508 catch_int_signal ();
45054509 UNBLOCK_SIGNALS (& curset );
4506-
4510+ # ifdef FEAT_JOB_CHANNEL
4511+ ++ dont_check_job_ended ;
4512+ # endif
45074513 /*
45084514 * For the GUI we redirect stdin, stdout and stderr to our window.
45094515 * This is also used to pipe stdin/stdout to/from the external
@@ -5052,6 +5058,10 @@ mch_call_shell(
50525058 wait4pid (wpid , NULL );
50535059 }
50545060
5061+ # ifdef FEAT_JOB_CHANNEL
5062+ -- dont_check_job_ended ;
5063+ # endif
5064+
50555065 /*
50565066 * Set to raw mode right now, otherwise a CTRL-C after
50575067 * catch_signals() will kill Vim.
@@ -5385,6 +5395,14 @@ mch_detect_ended_job(job_T *job_list)
53855395 pid_t wait_pid = 0 ;
53865396 job_T * job ;
53875397
5398+ # ifndef USE_SYSTEM
5399+ /* Do not do this when waiting for a shell command to finish, we would get
5400+ * the exit value here (and discard it), the exit value obtained there
5401+ * would then be wrong. */
5402+ if (dont_check_job_ended > 0 )
5403+ return NULL ;
5404+ # endif
5405+
53885406# ifdef __NeXT__
53895407 wait_pid = wait4 (-1 , & status , WNOHANG , (struct rusage * )0 );
53905408# else
0 commit comments