summaryrefslogtreecommitdiff
path: root/internal/worker.zsh
diff options
context:
space:
mode:
authorromkatv <roman.perepelitsa@gmail.com>2020-01-19 15:49:54 +0300
committerromkatv <roman.perepelitsa@gmail.com>2020-01-19 15:49:54 +0300
commit61df3d1cfb5e77625156386241942ce7eabebdde (patch)
treed53e83bfb6a99c7ee14ebbf51099a6c80d45be1b /internal/worker.zsh
parent23e8921b8d88a1699e5b1920f4da8efa127cd5d0 (diff)
even further simplify worker bootstrap
Diffstat (limited to 'internal/worker.zsh')
-rw-r--r--internal/worker.zsh31
1 files changed, 17 insertions, 14 deletions
diff --git a/internal/worker.zsh b/internal/worker.zsh
index ac9773da..180ad2be 100644
--- a/internal/worker.zsh
+++ b/internal/worker.zsh
@@ -61,7 +61,7 @@ function _p9k_worker_main() {
done
done
} always {
- kill -- -$$
+ kill -- -$sysparams[pid]
}
}
@@ -260,20 +260,23 @@ function _p9k_worker_start() {
local fifo=$_p9k__worker_file_prefix.fifo
local zsh=${${:-/proc/self/exe}:A}
[[ -x $zsh ]] || zsh=zsh
- local bootstrap=(
- '"emulate" "zsh" "-o" "no_aliases"'
- '{ zmodload zsh/system && mkfifo '${(q)fifo}' && exec >&4 && echo -n "s$sysparams[pid]\x1e" && exec 0<'${(q)fifo}' || exit } always { rm -f '${(q)fifo}' }'
- 'IFS= read -rd $'\''\x1e'\'' && eval $REPLY')
- local child='"eval" "$_p9k_worker_bootstrap" &!'
- local parent=(
- '"emulate" "-L" "zsh" "-o" "no_aliases" "-o" "no_bgnice"'
- 'echo PARENT $$ >>/tmp/log'
- '{ eval $_p9k_worker_bootstrap } &!'
- 'command true'
- )
+ local bootstrap='
+ "emulate" "-L" "zsh" "-o" "no_aliases" "-o" "no_bgnice"
+ {
+ local fifo='${(q)fifo}'
+ {
+ zmodload zsh/system &&
+ mkfifo $fifo &&
+ exec >&4 &&
+ echo -n "s$sysparams[pid]\x1e" &&
+ exec 0<$fifo || exit
+ } always { rm -f -- $fifo }
+ IFS= read -rd $'"'\\x1e'"' && eval $REPLY
+ } &!
+ command true'
sysopen -r -o cloexec -u _p9k__worker_resp_fd <(
- _p9k_worker_bootstrap=${(j:; :)bootstrap} \
- $zsh -${trace}dfmc ${(j:; :)parent} </dev/null 4>&1 &>>$log_file) || return
+ _p9k_worker_bootstrap=${bootstrap// ##} </dev/null 4>&1 &>>$log_file \
+ $zsh -${trace}dfmc '"eval" "$_p9k_worker_bootstrap"' ) || return
zle -F $_p9k__worker_resp_fd _p9k_worker_receive
_p9k__worker_shell_pid=$sysparams[pid]
add-zsh-hook zshexit _p9k_worker_cleanup