Created
December 17, 2015 21:39
-
-
Save corpix/dd4936ff60c9f8d52f0f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
leaf=$$ | |
ps -eo pid,ppid,command | awk -v leaf="$leaf" \ | |
'{parent[$1]=$2;command[$1]=$3;} | |
function print_ancestry(pid) | |
{ | |
print pid " (" command[pid] ") child of " parent[pid]; | |
if(pid!=1) print_ancestry(parent[pid]) | |
}; | |
END{\ | |
print_ancestry(leaf) | |
}' | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment