Skip to content

Commit c4d4ac2

Browse files
committed
patch 8.0.0071
Problem: Exit value from a shell command is wrong. (Hexchain Tong) Solution: Do not check for ended jobs while waiting for a shell command. (ichizok, closes #1196)
1 parent 3f9ebf3 commit c4d4ac2

2 files changed

Lines changed: 21 additions & 1 deletion

File tree

src/os_unix.c

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,10 @@ static volatile int deadly_signal = 0; /* The signal we caught */
238238
/* volatile because it is used in signal handler deathtrap(). */
239239
static 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+
241245
static 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

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -764,6 +764,8 @@ static char *(features[]) =
764764

765765
static int included_patches[] =
766766
{ /* Add new patch number below this line */
767+
/**/
768+
71,
767769
/**/
768770
70,
769771
/**/

0 commit comments

Comments
 (0)