Skip to content

Instantly share code, notes, and snippets.

@gkawamoto
Created September 3, 2020 17:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gkawamoto/094101d95f8e2cf8a11927f6e56f439f to your computer and use it in GitHub Desktop.
Save gkawamoto/094101d95f8e2cf8a11927f6e56f439f to your computer and use it in GitHub Desktop.
Simple script to list all parents from a given pid
#!/bin/bash
[ $# -lt 1 ] && {
echo 'inform the pid' >&2
exit 1
}
pid=$1
while true
do
ps -o pid,cmd -p $pid
[ $pid -eq 1 ] && break
pid=$(ps -o ppid -p $pid | tail -n1)
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment