diff options
author | romkatv <roman.perepelitsa@gmail.com> | 2019-07-24 20:42:47 +0300 |
---|---|---|
committer | romkatv <roman.perepelitsa@gmail.com> | 2019-07-24 20:42:47 +0300 |
commit | 6eaa39e37037f1d43ed24724eb472376bbf41086 (patch) | |
tree | 8b5e3116aa7ce31ef14f49139a656c86dfe13c5b | |
parent | 45760187f3d3031a4f7172413649ef1a50a6b585 (diff) |
daemonize async pump
-rwxr-xr-x | internal/p10k.zsh | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/internal/p10k.zsh b/internal/p10k.zsh index 67c5feb7..a67d730b 100755 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -3072,7 +3072,7 @@ function _p9k_async_pump() { emulate -L zsh || return setopt noaliases no_hist_expand extended_glob || return zmodload zsh/system zsh/datetime || return - echo ok || return + echo $$ || return local ip last_ip local -F next_ip_time @@ -3153,22 +3153,23 @@ _p9k_init_async_pump() { zle -F $_p9k_async_pump_fd _p9k_on_async_message 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 -a ip_methods=($_POWERLEVEL9K_PUBLIC_IP_METHODS) local -F tout=$_POWERLEVEL9K_PUBLIC_IP_TIMEOUT local ip_url=$_POWERLEVEL9K_PUBLIC_IP_HOST local lock=$_p9k_async_pump_lock local fifo=$_p9k_async_pump_fifo - $functions[_p9k_async_pump] - " </dev/null >&$_p9k_async_pump_fd 2>/dev/null &! + $functions[_p9k_async_pump]" - _p9k_async_pump_pid=$! - _p9k_async_pump_subshell=$ZSH_SUBSHELL + 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 &! - local resp - read -r -u $_p9k_async_pump_fd resp && [[ $resp == ok ]] + read -t 5 -r -u $_p9k_async_pump_fd _p9k_async_pump_pid && (( _p9k_async_pump_pid )) + _p9k_async_pump_subshell=$ZSH_SUBSHELL add-zsh-hook zshexit _p9k_kill_async_pump } |