From 2fafed6bb8aa316861173c39a89d0c9cca6cd4d9 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Wed, 14 Aug 2019 09:58:52 +0200 Subject: [PATCH] clipboard: handle/avoid SIGTERM with previous owner #10765 Fixes regression due to signal being reported with exit status. ref #10573 939d9053bdf2f56 ref https://github.com/neovim/neovim/issues/7054#issuecomment-520282429 --- runtime/autoload/provider/clipboard.vim | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/runtime/autoload/provider/clipboard.vim b/runtime/autoload/provider/clipboard.vim index ce140b0948..e33dc31f6d 100644 --- a/runtime/autoload/provider/clipboard.vim +++ b/runtime/autoload/provider/clipboard.vim @@ -159,9 +159,7 @@ function! s:clipboard.set(lines, regtype, reg) abort end if s:selections[a:reg].owner > 0 - " The previous provider instance should exit when the new one takes - " ownership, but kill it to be sure we don't fill up the job table. - call jobstop(s:selections[a:reg].owner) + let prev_job = s:selections[a:reg].owner end let s:selections[a:reg] = copy(s:selection) let selection = s:selections[a:reg] @@ -175,13 +173,23 @@ function! s:clipboard.set(lines, regtype, reg) abort call jobsend(jobid, a:lines) call jobclose(jobid, 'stdin') let selection.owner = jobid + let ret = 1 else echohl WarningMsg echomsg 'clipboard: failed to execute: '.(s:copy[a:reg]) echohl None - return 0 + let ret = 1 endif - return 1 + + " The previous provider instance should exit when the new one takes + " ownership, but kill it to be sure we don't fill up the job table. + if exists('prev_job') + call timer_start(1000, {... -> + \ jobwait([prev_job], 0)[0] == -1 + \ && jobstop(prev_job)}) + endif + + return ret endfunction function! provider#clipboard#Call(method, args) abort