diff options
author | David Wührer <def@gmx.at> | 2022-11-03 19:23:18 +0100 |
---|---|---|
committer | David Wührer <def@gmx.at> | 2022-11-03 19:23:18 +0100 |
commit | be555f29f47f81993c12bf76065a0cb6bb0fee96 (patch) | |
tree | eb5991d8b0309609746fe612068faeadf0c52e0b /pf | |
parent | e60829f7b9c61dc870173a8dd8f2f85c17517ec4 (diff) |
Add a few old things.
Diffstat (limited to 'pf')
-rwxr-xr-x | pf | 38 |
1 files changed, 38 insertions, 0 deletions
@@ -0,0 +1,38 @@ +#!/bin/bash + +set -ue + +get_parent () { + ps hoppid p$1 +} + +get_children () { + ps hopid --ppid "$1" +} + +get_ancestors () { + case $1 in + 1|'') : + ;; *) get_ancestors $(get_parent $1) + esac + echo "$1" +} + +get_descendents () { + for c in $(get_children "$1") + do echo "$c" + get_descendents "$c" + done +} + +declare -i p +for p in "$@" +do + [[ $p -ne 0 ]] && { + get_ancestors "$p" + get_descendents "$p" + } | { + readarray -t pids + ps -Hf "${pids[@]}" | sed "/^[^ ]* *$p /s/.*/[1m&[0m/" + } +done |