|
|
@ -1,7 +1,7 @@
|
|
|
|
# invoked in worker: _p9k_worker_main <timeout>
|
|
|
|
# invoked in worker: _p9k_worker_main <pgid>
|
|
|
|
function _p9k_worker_main() {
|
|
|
|
function _p9k_worker_main() {
|
|
|
|
zmodload zsh/zselect || return
|
|
|
|
local pgid=$1
|
|
|
|
! { zselect -t0 || (( $? != 1 )) } || return
|
|
|
|
|
|
|
|
mkfifo $_p9k__worker_file_prefix.fifo || return
|
|
|
|
mkfifo $_p9k__worker_file_prefix.fifo || return
|
|
|
|
echo -nE - s${1}$'\x1e' || return
|
|
|
|
echo -nE - s${1}$'\x1e' || return
|
|
|
|
exec 0<$_p9k__worker_file_prefix.fifo || return
|
|
|
|
exec 0<$_p9k__worker_file_prefix.fifo || return
|
|
|
@ -74,7 +74,7 @@ function _p9k_worker_main() {
|
|
|
|
done
|
|
|
|
done
|
|
|
|
done
|
|
|
|
done
|
|
|
|
} always {
|
|
|
|
} always {
|
|
|
|
kill -- -$sysparams[pid]
|
|
|
|
kill -- -$pgid
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -158,6 +158,7 @@ function _p9k_worker_receive() {
|
|
|
|
for resp in ${(ps:\x1e:)buf}; do
|
|
|
|
for resp in ${(ps:\x1e:)buf}; do
|
|
|
|
local arg=$resp[2,-1]
|
|
|
|
local arg=$resp[2,-1]
|
|
|
|
case $resp[1] in
|
|
|
|
case $resp[1] in
|
|
|
|
|
|
|
|
p) ;;
|
|
|
|
d)
|
|
|
|
d)
|
|
|
|
local req=$_p9k__worker_request_map[$arg]
|
|
|
|
local req=$_p9k__worker_request_map[$arg]
|
|
|
|
if [[ -n $req ]]; then
|
|
|
|
if [[ -n $req ]]; then
|
|
|
@ -222,8 +223,15 @@ function _p9k_worker_start() {
|
|
|
|
# todo: remove
|
|
|
|
# todo: remove
|
|
|
|
exec 2>>/tmp/log
|
|
|
|
exec 2>>/tmp/log
|
|
|
|
setopt xtrace
|
|
|
|
setopt xtrace
|
|
|
|
local pid=$sysparams[pid]
|
|
|
|
zmodload zsh/zselect || return
|
|
|
|
_p9k_worker_main $pid &
|
|
|
|
! { zselect -t0 || (( $? != 1 )) } || return
|
|
|
|
|
|
|
|
local pgid=$sysparams[pid]
|
|
|
|
|
|
|
|
_p9k_worker_main $pgid &
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
trap '' PIPE
|
|
|
|
|
|
|
|
while syswrite p$'\x1e'; do zselect -t 1000; done
|
|
|
|
|
|
|
|
kill -- -$pgid
|
|
|
|
|
|
|
|
} &
|
|
|
|
exec =true) || return
|
|
|
|
exec =true) || return
|
|
|
|
zle -F $_p9k__worker_resp_fd _p9k_worker_receive
|
|
|
|
zle -F $_p9k__worker_resp_fd _p9k_worker_receive
|
|
|
|
_p9k__worker_shell_pid=$sysparams[pid]
|
|
|
|
_p9k__worker_shell_pid=$sysparams[pid]
|
|
|
|