Reset SIGINT handler in background processes
In a noninteractive shell, asynchronous commands ignore SIGINT and SIGQUIT. We typically use such shells to feed fifo buffers which we do want to cancel them on Control-C. Make it so. Same for SIGQUIT; that one is not typically used but I expect that along the Kakoune server it kills any child processes that (haven't been daemonized). Note that for unknown reasons, Bash already doesn't ignore SIGINT in async processes that use "eval". Note that Dash has a bug that prevents this from working; proposed fix is at https://lore.kernel.org/dash/20240329153905.154792-2-aclopte@gmail.com/ (While at it balance out some parens, to help the m command)
This commit is contained in:
parent
5d00b80d1a
commit
7b93567bb1
|
@ -36,16 +36,17 @@ define-command -params ..1 \
|
||||||
# position and a buffer timestamp, only valid completions should be
|
# position and a buffer timestamp, only valid completions should be
|
||||||
# displayed.
|
# displayed.
|
||||||
((
|
((
|
||||||
|
trap - INT QUIT
|
||||||
until [ -f ${dir}/buf ]; do :; done # wait for the buffer to be written
|
until [ -f ${dir}/buf ]; do :; done # wait for the buffer to be written
|
||||||
|
|
||||||
if [ -n "$kak_opt_clang_directory" ]; then
|
if [ -n "$kak_opt_clang_directory" ]; then
|
||||||
cd "$kak_opt_clang_directory"
|
cd "$kak_opt_clang_directory"
|
||||||
fi
|
fi
|
||||||
case ${kak_opt_filetype} in
|
case ${kak_opt_filetype} in
|
||||||
c) ft=c ;;
|
(c) ft=c ;;
|
||||||
cpp) ft=c++ ;;
|
(cpp) ft=c++ ;;
|
||||||
obj-c) ft=objective-c ;;
|
(obj-c) ft=objective-c ;;
|
||||||
*) ft=c++ ;;
|
(*) ft=c++ ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
if [ "$1" = "-complete" ]; then
|
if [ "$1" = "-complete" ]; then
|
||||||
|
|
|
@ -112,6 +112,7 @@ declare-option -docstring "path to the directory in which the tags file will be
|
||||||
define-command ctags-generate -docstring 'Generate tag file asynchronously' %{
|
define-command ctags-generate -docstring 'Generate tag file asynchronously' %{
|
||||||
echo -markup "{Information}launching tag generation in the background"
|
echo -markup "{Information}launching tag generation in the background"
|
||||||
nop %sh{ (
|
nop %sh{ (
|
||||||
|
trap - INT QUIT
|
||||||
while ! mkdir .tags.kaklock 2>/dev/null; do sleep 1; done
|
while ! mkdir .tags.kaklock 2>/dev/null; do sleep 1; done
|
||||||
trap 'rmdir .tags.kaklock' EXIT
|
trap 'rmdir .tags.kaklock' EXIT
|
||||||
|
|
||||||
|
@ -128,6 +129,7 @@ define-command ctags-generate -docstring 'Generate tag file asynchronously' %{
|
||||||
|
|
||||||
define-command ctags-update-tags -docstring 'Update tags for the given file' %{
|
define-command ctags-update-tags -docstring 'Update tags for the given file' %{
|
||||||
nop %sh{ (
|
nop %sh{ (
|
||||||
|
trap - INT QUIT
|
||||||
while ! mkdir .tags.kaklock 2>/dev/null; do sleep 1; done
|
while ! mkdir .tags.kaklock 2>/dev/null; do sleep 1; done
|
||||||
trap 'rmdir .tags.kaklock' EXIT
|
trap 'rmdir .tags.kaklock' EXIT
|
||||||
|
|
||||||
|
|
|
@ -164,7 +164,7 @@ define-command -params 1.. \
|
||||||
esac
|
esac
|
||||||
output=$(mktemp -d "${TMPDIR:-/tmp}"/kak-git.XXXXXXXX)/fifo
|
output=$(mktemp -d "${TMPDIR:-/tmp}"/kak-git.XXXXXXXX)/fifo
|
||||||
mkfifo ${output}
|
mkfifo ${output}
|
||||||
( git "$@" > ${output} 2>&1 & ) > /dev/null 2>&1 < /dev/null
|
( trap - INT QUIT; git "$@" > ${output} 2>&1 & ) > /dev/null 2>&1 < /dev/null
|
||||||
|
|
||||||
printf %s "evaluate-commands -try-client '$kak_opt_docsclient' '
|
printf %s "evaluate-commands -try-client '$kak_opt_docsclient' '
|
||||||
edit! -fifo ${output} *git*
|
edit! -fifo ${output} *git*
|
||||||
|
@ -283,6 +283,7 @@ define-command -params 1.. \
|
||||||
echo 'map window normal <ret> %{:git blame-jump<ret>}'
|
echo 'map window normal <ret> %{:git blame-jump<ret>}'
|
||||||
echo 'echo -markup {Information}Press <ret> to jump to blamed commit'
|
echo 'echo -markup {Information}Press <ret> to jump to blamed commit'
|
||||||
(
|
(
|
||||||
|
trap - INT QUIT
|
||||||
cd_bufdir
|
cd_bufdir
|
||||||
printf %s "evaluate-commands -client '$kak_client' %{
|
printf %s "evaluate-commands -client '$kak_client' %{
|
||||||
set-option buffer=$kak_bufname git_blame_flags '$kak_timestamp'
|
set-option buffer=$kak_bufname git_blame_flags '$kak_timestamp'
|
||||||
|
|
|
@ -84,8 +84,8 @@ define-command -hidden -params 0 gopls-ref %{
|
||||||
evaluate-commands %sh{
|
evaluate-commands %sh{
|
||||||
dir=${kak_opt_gopls_tmp_dir}
|
dir=${kak_opt_gopls_tmp_dir}
|
||||||
mkfifo "${dir}/fifo"
|
mkfifo "${dir}/fifo"
|
||||||
( gopls references "${kak_buffile}:${kak_cursor_line}:${kak_cursor_column}" \
|
( { trap - INT QUIT; gopls references "${kak_buffile}:${kak_cursor_line}:${kak_cursor_column}"
|
||||||
> "${dir}/fifo" 2> /dev/null & ) > /dev/null 2>&1 < /dev/null
|
} > "${dir}/fifo" 2> /dev/null & ) > /dev/null 2>&1 < /dev/null
|
||||||
# using filetype=grep for nice hilight and <ret> mapping
|
# using filetype=grep for nice hilight and <ret> mapping
|
||||||
printf %s\\n "evaluate-commands -try-client '${kak_opt_toolsclient}' %{
|
printf %s\\n "evaluate-commands -try-client '${kak_opt_toolsclient}' %{
|
||||||
edit! -fifo '${dir}/fifo' *gopls-refs*
|
edit! -fifo '${dir}/fifo' *gopls-refs*
|
||||||
|
|
|
@ -26,7 +26,7 @@ define-command -params .. -docstring %{
|
||||||
|
|
||||||
output=$(mktemp -d "${TMPDIR:-/tmp}"/kak-grep.XXXXXXXX)/fifo
|
output=$(mktemp -d "${TMPDIR:-/tmp}"/kak-grep.XXXXXXXX)/fifo
|
||||||
mkfifo ${output}
|
mkfifo ${output}
|
||||||
( ${kak_opt_grepcmd} "$@" 2>&1 | tr -d '\r' > ${output} 2>&1 & ) > /dev/null 2>&1 < /dev/null
|
( { trap - INT QUIT; ${kak_opt_grepcmd} "$@" 2>&1 | tr -d '\r'; } > ${output} 2>&1 & ) > /dev/null 2>&1 < /dev/null
|
||||||
|
|
||||||
printf %s\\n "evaluate-commands -try-client '$kak_opt_toolsclient' %{
|
printf %s\\n "evaluate-commands -try-client '$kak_opt_toolsclient' %{
|
||||||
edit! -fifo ${output} *grep*
|
edit! -fifo ${output} *grep*
|
||||||
|
|
|
@ -74,6 +74,7 @@ define-command \
|
||||||
# but shellcheck isn't a fan.
|
# but shellcheck isn't a fan.
|
||||||
# shellcheck disable=SC2094
|
# shellcheck disable=SC2094
|
||||||
({ # do the parsing in the background and when ready send to the session
|
({ # do the parsing in the background and when ready send to the session
|
||||||
|
trap - INT QUIT
|
||||||
|
|
||||||
for selpath in "$dir"/sel-*; do
|
for selpath in "$dir"/sel-*; do
|
||||||
# Read in the line and column offset of this selection.
|
# Read in the line and column offset of this selection.
|
||||||
|
|
|
@ -14,7 +14,7 @@ define-command -params .. \
|
||||||
} make %{ evaluate-commands %sh{
|
} make %{ evaluate-commands %sh{
|
||||||
output=$(mktemp -d "${TMPDIR:-/tmp}"/kak-make.XXXXXXXX)/fifo
|
output=$(mktemp -d "${TMPDIR:-/tmp}"/kak-make.XXXXXXXX)/fifo
|
||||||
mkfifo ${output}
|
mkfifo ${output}
|
||||||
( eval "${kak_opt_makecmd}" "$@" > ${output} 2>&1 & ) > /dev/null 2>&1 < /dev/null
|
( { trap - INT QUIT; eval "${kak_opt_makecmd}" "$@"; } > ${output} 2>&1 & ) > /dev/null 2>&1 < /dev/null
|
||||||
|
|
||||||
printf %s\\n "evaluate-commands -try-client '$kak_opt_toolsclient' %{
|
printf %s\\n "evaluate-commands -try-client '$kak_opt_toolsclient' %{
|
||||||
edit! -fifo ${output} -scroll *make*
|
edit! -fifo ${output} -scroll *make*
|
||||||
|
|
|
@ -20,6 +20,7 @@ define-command jedi-complete -docstring "Complete the current selection" %{
|
||||||
dir=${kak_opt_jedi_tmp_dir}
|
dir=${kak_opt_jedi_tmp_dir}
|
||||||
printf %s\\n "evaluate-commands -draft %{ edit! -fifo ${dir}/fifo *jedi-output* }"
|
printf %s\\n "evaluate-commands -draft %{ edit! -fifo ${dir}/fifo *jedi-output* }"
|
||||||
((
|
((
|
||||||
|
trap - INT QUIT
|
||||||
cd $(dirname ${kak_buffile})
|
cd $(dirname ${kak_buffile})
|
||||||
|
|
||||||
export PYTHONPATH="$kak_opt_jedi_python_path:$PYTHONPATH"
|
export PYTHONPATH="$kak_opt_jedi_python_path:$PYTHONPATH"
|
||||||
|
|
|
@ -16,6 +16,7 @@ define-command racer-complete -docstring "Complete the current selection with ra
|
||||||
evaluate-commands %sh{
|
evaluate-commands %sh{
|
||||||
dir=${kak_opt_racer_tmp_dir}
|
dir=${kak_opt_racer_tmp_dir}
|
||||||
(
|
(
|
||||||
|
trap - INT QUIT
|
||||||
cursor="${kak_cursor_line} $((${kak_cursor_column} - 1))"
|
cursor="${kak_cursor_line} $((${kak_cursor_column} - 1))"
|
||||||
racer_data=$(racer --interface tab-text complete-with-snippet ${cursor} ${kak_buffile} ${dir}/buf)
|
racer_data=$(racer --interface tab-text complete-with-snippet ${cursor} ${kak_buffile} ${dir}/buf)
|
||||||
compl=$(printf %s\\n "${racer_data}" | awk '
|
compl=$(printf %s\\n "${racer_data}" | awk '
|
||||||
|
|
|
@ -32,6 +32,7 @@ define-command -params ..1 -docstring %{
|
||||||
printf 'eval -no-hooks write %s\n' "${kak_response_fifo}" > $kak_command_fifo
|
printf 'eval -no-hooks write %s\n' "${kak_response_fifo}" > $kak_command_fifo
|
||||||
|
|
||||||
{
|
{
|
||||||
|
trap - INT QUIT
|
||||||
sed 's/^/^/' | eval "aspell --byte-offsets -a $options" 2>&1 | awk '
|
sed 's/^/^/' | eval "aspell --byte-offsets -a $options" 2>&1 | awk '
|
||||||
BEGIN {
|
BEGIN {
|
||||||
line_num = 1
|
line_num = 1
|
||||||
|
|
Loading…
Reference in New Issue
Block a user