# HG changeset patch # User Bram Moolenaar # Date 1581367503 -3600 # Node ID 16d538568dc882dc3ff352ed3655c6e7bb31024b # Parent 46d8c023834eca65ac2311582ddcde104a22dd12 patch 8.2.0238: MS-Windows: job_stop() results in exit value zero Commit: https://github.com/vim/vim/commit/b3e195cca7b3201b188c1713b64012b1bef4f61f Author: Bram Moolenaar Date: Mon Feb 10 21:32:19 2020 +0100 patch 8.2.0238: MS-Windows: job_stop() results in exit value zero Problem: MS-Windows: job_stop() results in exit value zero. Solution: Call TerminateJobObject() with -1 instead of 0. (Yasuhiro Matsumoto, closes #5150, closes #5614) diff --git a/src/os_win32.c b/src/os_win32.c --- a/src/os_win32.c +++ b/src/os_win32.c @@ -5384,9 +5384,9 @@ mch_signal_job(job_T *job, char_u *how) { if (job->jv_channel != NULL && job->jv_channel->ch_anonymous_pipe) job->jv_channel->ch_killing = TRUE; - return TerminateJobObject(job->jv_job_object, 0) ? OK : FAIL; + return TerminateJobObject(job->jv_job_object, -1) ? OK : FAIL; } - return terminate_all(job->jv_proc_info.hProcess, 0) ? OK : FAIL; + return terminate_all(job->jv_proc_info.hProcess, -1) ? OK : FAIL; } if (!AttachConsole(job->jv_proc_info.dwProcessId)) diff --git a/src/testdir/test_channel.vim b/src/testdir/test_channel.vim --- a/src/testdir/test_channel.vim +++ b/src/testdir/test_channel.vim @@ -1991,3 +1991,18 @@ func Test_job_start_fails() " this was leaking memory call assert_fails("call job_start([''])", "E474:") endfunc + +func Test_issue_5150() + let g:job = job_start('grep foo', {}) + call job_stop(g:job) + sleep 10m + call assert_equal(-1, job_info(g:job).exitval) + let g:job = job_start('grep foo', {}) + call job_stop(g:job, 'term') + sleep 10m + call assert_equal(-1, job_info(g:job).exitval) + let g:job = job_start('grep foo', {}) + call job_stop(g:job, 'kill') + sleep 10m + call assert_equal(-1, job_info(g:job).exitval) +endfunc diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -743,6 +743,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 238, +/**/ 237, /**/ 236,