Created
August 13, 2021 17:28
-
-
Save tangnotes/062e08d46ae3b3ed823c2f80d4a3b4cb to your computer and use it in GitHub Desktop.
This file contains hidden or 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
function getPPID() { | |
_pid0=$1 | |
_pid=`ps --no-header -o pid -p $_pid0` | |
if [ "x$_pid" == "x" ] | |
then | |
echo "Error: $_pid0 does not exists" | |
return | |
fi | |
echo -n "$_pid > " | |
_ppid=`ps --no-header -o ppid -p $_pid` | |
if [ "x$_ppid" == "x" ] || [ $_ppid -le 1 ] | |
then | |
echo $_ppid | |
return | |
fi | |
getPPID $_ppid | |
} | |
getPPID $1 | |
echo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment