Last active
March 28, 2020 14:26
-
-
Save x-yuri/b1293c8829343c84965f829e79cdfbbb 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
#!/bin/sh | |
set -eu | |
pids=$(ps -eHo pid,ppid \ | |
| awk -vpid="$1" ' | |
BEGIN { pids[pid] } | |
$1 in pids || $2 in pids { | |
print $1 | |
pids[$1] | |
} | |
') | |
ps -Ho pid,ppid,comm,args $pids | |
# ps -Ho pid,ppid,comm,args $(ps -eHo pid,ppid | awk -vpid="$1" 'BEGIN { pids[pid] } $1 in pids || $2 in pids {print $1; pids[$1]}') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment