summaryrefslogtreecommitdiff
path: root/autoload
diff options
context:
space:
mode:
authorw0rp <devw0rp@gmail.com>2017-02-11 00:08:05 +0000
committerw0rp <devw0rp@gmail.com>2017-02-11 00:08:05 +0000
commit14c38cdb6363147e224eb82af85d9d3c865e6ba2 (patch)
tree6f591ffdfe5d096b0aa11708ddcdebbc439eb2dd /autoload
parent81779e60bb756454b90c3fa901186290ec74ef91 (diff)
downloadale-14c38cdb6363147e224eb82af85d9d3c865e6ba2.zip
Fix #116 - Send SIGKILL to processes if they don't respond to SIGTERM
Diffstat (limited to 'autoload')
-rw-r--r--autoload/ale/engine.vim19
1 files changed, 18 insertions, 1 deletions
diff --git a/autoload/ale/engine.vim b/autoload/ale/engine.vim
index cd4c7b93..d1bc9448 100644
--- a/autoload/ale/engine.vim
+++ b/autoload/ale/engine.vim
@@ -33,6 +33,14 @@ function! ale#engine#InitBufferInfo(buffer) abort
endif
endfunction
+" A map from timer IDs to Vim 8 jobs, for tracking jobs that need to be killed
+" with SIGKILL if they don't terminate right away.
+let s:job_kill_timers = {}
+
+function! s:KillHandler(timer) abort
+ call job_stop(remove(s:job_kill_timers, a:timer), 'kill')
+endfunction
+
function! ale#engine#ClearJob(job) abort
let l:job_id = s:GetJobID(a:job)
let l:linter = s:job_info_map[l:job_id].linter
@@ -46,10 +54,19 @@ function! ale#engine#ClearJob(job) abort
call ch_close_in(job_getchannel(a:job))
endif
+ " Ask nicely for the job to stop.
call job_stop(a:job)
+
+ " If a job doesn't stop immediately, queue a timer which will
+ " send SIGKILL to the job, if it's alive by the time the timer ticks.
+ if job_status(a:job) ==# 'run'
+ let s:job_kill_timers[timer_start(100, function('s:KillHandler'))] = a:job
+ endif
endif
- call remove(s:job_info_map, l:job_id)
+ if has_key(s:job_info_map, l:job_id)
+ call remove(s:job_info_map, l:job_id)
+ endif
endfunction
function! s:StopPreviousJobs(buffer, linter) abort