Skip to content

Commit 923d926

Browse files
committed
patch 7.4.1418
Problem: job_stop() on MS-Windows does not really stop the job. Solution: Make the default to stop the job forcefully. (Ken Takata) Make MS-Windows and Unix more similar.
1 parent 265f64e commit 923d926

4 files changed

Lines changed: 33 additions & 24 deletions

File tree

runtime/doc/eval.txt

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4474,21 +4474,27 @@ job_status({job}) *job_status()* *E916*
44744474
job_stop({job} [, {how}]) *job_stop()*
44754475
Stop the {job}. This can also be used to signal the job.
44764476

4477-
When {how} is omitted or is "term" the job will be terminated
4478-
normally. For Unix SIGTERM is sent. For MS-Windows
4479-
CTRL_BREAK will be sent. This goes to the process group, thus
4480-
children may also be affected.
4481-
4482-
Other values for Unix:
4483-
"hup" Unix: SIGHUP
4484-
"quit" Unix: SIGQUIT
4485-
"kill" Unix: SIGKILL (strongest way to stop)
4486-
number Unix: signal with that number
4487-
4488-
Other values for MS-Windows:
4489-
"int" Windows: CTRL_C
4490-
"kill" Windows: terminate process forcedly
4491-
Others Windows: CTRL_BREAK
4477+
When {how} is omitted or is "term" the job will be terminated.
4478+
For Unix SIGTERM is sent. On MS-Windows the job will be
4479+
terminated forcedly (there is no "gentle" way).
4480+
This goes to the process group, thus children may also be
4481+
affected.
4482+
4483+
Effect for Unix:
4484+
"term" SIGTERM (default)
4485+
"hup" SIGHUP
4486+
"quit" SIGQUIT
4487+
"int" SIGINT
4488+
"kill" SIGKILL (strongest way to stop)
4489+
number signal with that number
4490+
4491+
Effect for MS-Windows:
4492+
"term" terminate process forcedly (default)
4493+
"hup" CTRL_BREAK
4494+
"quit" CTRL_BREAK
4495+
"int" CTRL_C
4496+
"kill" terminate process forcedly
4497+
Others CTRL_BREAK
44924498

44934499
On Unix the signal is sent to the process group. This means
44944500
that when the job is "sh -c command" it affects both the shell

src/os_unix.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5202,12 +5202,14 @@ mch_stop_job(job_T *job, char_u *how)
52025202
int sig = -1;
52035203
pid_t job_pid;
52045204

5205-
if (STRCMP(how, "hup") == 0)
5206-
sig = SIGHUP;
5207-
else if (*how == NUL || STRCMP(how, "term") == 0)
5205+
if (*how == NUL || STRCMP(how, "term") == 0)
52085206
sig = SIGTERM;
5207+
else if (STRCMP(how, "hup") == 0)
5208+
sig = SIGHUP;
52095209
else if (STRCMP(how, "quit") == 0)
52105210
sig = SIGQUIT;
5211+
else if (STRCMP(how, "int") == 0)
5212+
sig = SIGINT;
52115213
else if (STRCMP(how, "kill") == 0)
52125214
sig = SIGKILL;
52135215
else if (isdigit(*how))

src/os_win32.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5141,10 +5141,9 @@ mch_job_status(job_T *job)
51415141
int
51425142
mch_stop_job(job_T *job, char_u *how)
51435143
{
5144-
int ret = 0;
5145-
int ctrl_c = STRCMP(how, "int") == 0;
5144+
int ret;
51465145

5147-
if (STRCMP(how, "kill") == 0)
5146+
if (STRCMP(how, "term") == 0 || STRCMP(how, "kill") == 0 || *how == NUL)
51485147
{
51495148
if (job->jv_job_object != NULL)
51505149
return TerminateJobObject(job->jv_job_object, 0) ? OK : FAIL;
@@ -5155,9 +5154,9 @@ mch_stop_job(job_T *job, char_u *how)
51555154
if (!AttachConsole(job->jv_proc_info.dwProcessId))
51565155
return FAIL;
51575156
ret = GenerateConsoleCtrlEvent(
5158-
ctrl_c ? CTRL_C_EVENT : CTRL_BREAK_EVENT,
5159-
job->jv_proc_info.dwProcessId)
5160-
? OK : FAIL;
5157+
STRCMP(how, "int") == 0 ? CTRL_C_EVENT : CTRL_BREAK_EVENT,
5158+
job->jv_proc_info.dwProcessId)
5159+
? OK : FAIL;
51615160
FreeConsole();
51625161
return ret;
51635162
}

src/version.c

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

749749
static int included_patches[] =
750750
{ /* Add new patch number below this line */
751+
/**/
752+
1418,
751753
/**/
752754
1417,
753755
/**/

0 commit comments

Comments
 (0)