Add some debugging functions

This commit is contained in:
crater2150 2019-07-08 16:09:39 +02:00
parent 253a43b45b
commit d45f674711
2 changed files with 18 additions and 0 deletions

5
functions/@ Normal file
View file

@ -0,0 +1,5 @@
#!/bin/zsh
# for debugging: prefix any command with @ to print it before execution
function @() {
echo "$*"; "$@"
}

13
functions/parent-user Normal file
View file

@ -0,0 +1,13 @@
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
}