1
0
Fork 0
mirror of https://github.com/romkatv/powerlevel10k.git synced 2024-11-25 21:40:08 +00:00

daemonize async pump

This commit is contained in:
romkatv 2019-07-24 19:42:47 +02:00
parent 45760187f3
commit 6eaa39e370

View file

@ -3072,7 +3072,7 @@ function _p9k_async_pump() {
emulate -L zsh || return emulate -L zsh || return
setopt noaliases no_hist_expand extended_glob || return setopt noaliases no_hist_expand extended_glob || return
zmodload zsh/system zsh/datetime || return zmodload zsh/system zsh/datetime || return
echo ok || return echo $$ || return
local ip last_ip local ip last_ip
local -F next_ip_time local -F next_ip_time
@ -3153,22 +3153,23 @@ _p9k_init_async_pump() {
zle -F $_p9k_async_pump_fd _p9k_on_async_message zle -F $_p9k_async_pump_fd _p9k_on_async_message
zsystem flock -f _p9k_async_pump_lock_fd $_p9k_async_pump_lock zsystem flock -f _p9k_async_pump_lock_fd $_p9k_async_pump_lock
zsh -dfc " local cmd="
local -i public_ip=$public_ip time_realtime=$time_realtime parent_pid=$$ local -i public_ip=$public_ip time_realtime=$time_realtime parent_pid=$$
local -a ip_methods=($_POWERLEVEL9K_PUBLIC_IP_METHODS) local -a ip_methods=($_POWERLEVEL9K_PUBLIC_IP_METHODS)
local -F tout=$_POWERLEVEL9K_PUBLIC_IP_TIMEOUT local -F tout=$_POWERLEVEL9K_PUBLIC_IP_TIMEOUT
local ip_url=$_POWERLEVEL9K_PUBLIC_IP_HOST local ip_url=$_POWERLEVEL9K_PUBLIC_IP_HOST
local lock=$_p9k_async_pump_lock local lock=$_p9k_async_pump_lock
local fifo=$_p9k_async_pump_fifo local fifo=$_p9k_async_pump_fifo
$functions[_p9k_async_pump] $functions[_p9k_async_pump]"
" </dev/null >&$_p9k_async_pump_fd 2>/dev/null &!
local setsid=${commands[setsid]:-/usr/local/opt/util-linux/bin/setsid}
[[ -f $setsid ]] && setsid=${(q)setsid} || setsid=
cmd="$setsid zsh -dfxc ${(q)cmd} &!"
zsh -dfmxc $cmd </dev/null >&$_p9k_async_pump_fd 2>/dev/null &!
read -t 5 -r -u $_p9k_async_pump_fd _p9k_async_pump_pid && (( _p9k_async_pump_pid ))
_p9k_async_pump_pid=$!
_p9k_async_pump_subshell=$ZSH_SUBSHELL _p9k_async_pump_subshell=$ZSH_SUBSHELL
local resp
read -r -u $_p9k_async_pump_fd resp && [[ $resp == ok ]]
add-zsh-hook zshexit _p9k_kill_async_pump add-zsh-hook zshexit _p9k_kill_async_pump
} }