Initial commit

This commit is contained in:
2018-04-30 02:53:44 +02:00
commit f39b0fbcd8
26 changed files with 1755 additions and 0 deletions

View File

@@ -0,0 +1,22 @@
#!/usr/bin/env bash
function top_level_parent_pid {
# Look up the parent of the given PID.
pid=${1:-$$}
stat=($(</proc/${pid}/stat))
ppid=${stat[3]}
# /sbin/init always has a PID of 1, so if you reach that, the current PID is
# the top-level parent. Otherwise, keep looking.
if [[ ${ppid} -eq 1 ]] ; then
echo ${pid}
else
top_level_parent_pid ${ppid}
fi
}
echo "Top Level Parent Pid: $(top_level_parent_pid)"
echo "Top Level Command: $(ps -o cmd= $(top_level_parent_pid))"
exit 0