zsh/functions/parent-user
2019-07-08 16:09:39 +02:00

14 lines
290 B
Plaintext

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
}