zsh/functions/parent-user

14 lines
290 B
Plaintext
Raw Normal View History

2019-07-08 14:09:39 +00:00
function parent-user() {
pid=${1:-$$}
uid=${2:-$(piduser $pid)}
stat=($(</proc/${pid}/stat))
ppid=${stat[4]}; echo $ppid
puid=$(piduser $ppid )
if [[ ${puid} != $uid ]]; then
echo ${puid}
elif [[ $ppid != 1 ]]; then
parent-user ${ppid}
fi
}