Open DanielThomas opened 3 months ago
Can you reproduce this with the following command?
() {
emulate -L zsh -o err_return -o xtrace
if [[ -e ~/powerlevel10k ]]; then
command git -C ~/powerlevel10k pull
else
command git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ~/powerlevel10k
fi
command rm -rf ~/z
command mkdir -p ~/z
command cat >~/z/.zshrc <<\END
source ~/z/.p10k.zsh
source ~/powerlevel10k/powerlevel10k.zsh-theme
END
command cat >~/z/.p10k.zsh <<\END
POWERLEVEL9K_MODE=ascii
POWERLEVEL9K_DISABLE_HOT_RELOAD=true
END
repeat 10 ZDOTDIR=~/z command zsh --no-globalrcs -ic 'echo hi'
command sleep 1
command ps -ef | command grep -E 'echo hi$'
}
Yes, rarely. When I do this manually from my regular shell I can reproduce almost every time. It might be a complete coincidence, but it seems to help if I start from scratch (i.e. remove z
and powerlevel10k
directories) before running the function:
+(anon):3> [[ -e /Users/dannyt/powerlevel10k ]]
+(anon):6> git clone '--depth=1' https://github.com/romkatv/powerlevel10k.git /Users/dannyt/powerlevel10k
Cloning into '/Users/dannyt/powerlevel10k'...
remote: Enumerating objects: 92, done.
remote: Counting objects: 100% (92/92), done.
remote: Compressing objects: 100% (75/75), done.
remote: Total 92 (delta 18), reused 77 (delta 13), pack-reused 0
Receiving objects: 100% (92/92), 349.37 KiB | 5.54 MiB/s, done.
Resolving deltas: 100% (18/18), done.
+(anon):9> rm -rf /Users/dannyt/z
+(anon):10> mkdir -p /Users/dannyt/z
+(anon):12> cat
+(anon):17> cat
+(anon):22> ZDOTDIR=/Users/dannyt/z zsh --no-globalrcs -ic 'echo hi'
hi
+(anon):22> ZDOTDIR=/Users/dannyt/z zsh --no-globalrcs -ic 'echo hi'
hi
+(anon):22> ZDOTDIR=/Users/dannyt/z zsh --no-globalrcs -ic 'echo hi'
hi
+(anon):22> ZDOTDIR=/Users/dannyt/z zsh --no-globalrcs -ic 'echo hi'
hi
+(anon):22> ZDOTDIR=/Users/dannyt/z zsh --no-globalrcs -ic 'echo hi'
hi
+(anon):22> ZDOTDIR=/Users/dannyt/z zsh --no-globalrcs -ic 'echo hi'
hi
+(anon):22> ZDOTDIR=/Users/dannyt/z zsh --no-globalrcs -ic 'echo hi'
hi
+(anon):22> ZDOTDIR=/Users/dannyt/z zsh --no-globalrcs -ic 'echo hi'
hi
+(anon):22> ZDOTDIR=/Users/dannyt/z zsh --no-globalrcs -ic 'echo hi'
hi
+(anon):22> ZDOTDIR=/Users/dannyt/z zsh --no-globalrcs -ic 'echo hi'
hi
+(anon):23> sleep 1
+(anon):24> ps -ef
+(anon):24> grep -E 'echo hi$'
501 21276 1 0 9:47am ttys001 0:00.00 zsh --no_globalrcs -ic echo hi
501 21277 1 0 9:47am ttys001 0:00.00 zsh --no_globalrcs -ic echo hi
❯ ps -ef | grep -E 'echo hi$'
501 21276 1 0 9:47am ttys001 0:00.00 zsh --no_globalrcs -ic echo hi
Can you reproduce this if you replace sleep 1
with sleep 10
?
Yeah:
+(anon):3> [[ -e /Users/dannyt/powerlevel10k ]]
+(anon):6> git clone '--depth=1' https://github.com/romkatv/powerlevel10k.git /Users/dannyt/powerlevel10k
Cloning into '/Users/dannyt/powerlevel10k'...
remote: Enumerating objects: 92, done.
remote: Counting objects: 100% (92/92), done.
remote: Compressing objects: 100% (75/75), done.
remote: Total 92 (delta 18), reused 77 (delta 13), pack-reused 0
Receiving objects: 100% (92/92), 349.37 KiB | 5.06 MiB/s, done.
Resolving deltas: 100% (18/18), done.
+(anon):9> rm -rf /Users/dannyt/z
+(anon):10> mkdir -p /Users/dannyt/z
+(anon):12> cat
+(anon):17> cat
+(anon):22> ZDOTDIR=/Users/dannyt/z zsh --no-globalrcs -ic 'echo hi'
hi
+(anon):22> ZDOTDIR=/Users/dannyt/z zsh --no-globalrcs -ic 'echo hi'
hi
+(anon):22> ZDOTDIR=/Users/dannyt/z zsh --no-globalrcs -ic 'echo hi'
hi
+(anon):22> ZDOTDIR=/Users/dannyt/z zsh --no-globalrcs -ic 'echo hi'
hi
+(anon):22> ZDOTDIR=/Users/dannyt/z zsh --no-globalrcs -ic 'echo hi'
hi
+(anon):22> ZDOTDIR=/Users/dannyt/z zsh --no-globalrcs -ic 'echo hi'
hi
+(anon):22> ZDOTDIR=/Users/dannyt/z zsh --no-globalrcs -ic 'echo hi'
hi
+(anon):22> ZDOTDIR=/Users/dannyt/z zsh --no-globalrcs -ic 'echo hi'
hi
+(anon):22> ZDOTDIR=/Users/dannyt/z zsh --no-globalrcs -ic 'echo hi'
hi
+(anon):22> ZDOTDIR=/Users/dannyt/z zsh --no-globalrcs -ic 'echo hi'
hi
+(anon):23> sleep 10
+(anon):24> ps -ef
+(anon):24> grep -E 'echo hi$'
501 70025 1 0 7:25pm ttys004 0:00.00 zsh --no_globalrcs -ic echo hi
They don't linger forever, do they?
Yes, when they hang up like this, it seems they do:
❯ ps -ef | grep -E 'echo hi$'
501 70025 1 0 7:25pm ttys004 0:00.00 zsh --no_globalrcs -ic echo hi
❯ date
Mon 15 Apr 2024 19:38:13 AEST
Interesting. I cannot reproduce this. I'll dig into this.
Thanks, let me know if there's anything else I can do to eliminate problems here. It's a real head scratcher.
What is the output of this command?
typeset -pm 'P9K_SSH|_P9K_SSH_TTY|TTY'
true &; ZDOTDIR=~/z zsh --no-globalrcs -ic 'echo hi'; true&
I am assuming you have ~/powerlevel10k
and ~/z
left over from the previous command.
❯ typeset -pm 'P9K_SSH|_P9K_SSH_TTY|TTY'
true &; ZDOTDIR=~/z zsh --no-globalrcs -ic 'echo hi'; true&
typeset TTY=/dev/ttys004
export _P9K_SSH_TTY=/dev/ttys004
export -i P9K_SSH=0
[1] 18891
[1] + 18891 done true
hi
[1] 18897
[1] + 18897 done true
I noticed that when using powerlevel10k, commands run by tools forcing an interactive shell leave orphaned
zsh
processes owned bylaunchd
. In this case they're doing this to get the interactive environment for the user, I believe IntelliJ and VSCode do something similar:I can reproduce if I run commands interactively:
One of the processes exits soon after, but the other stays running indefinitely:
I bisected my
.zshrc
and confirmed that disabling powerlevel10k avoids the problem. That's as much as I've been able to discover I'm afraid, it's not obvious to me which of the spawned shells this is: