thegates/sandbox/kinda-safe-godot/list_child_processes.sh
2024-05-04 00:14:24 +04:00

13 lines
247 B
Bash

#!/bin/bash
extract_child_pid() {
echo "$(ps --ppid $1)" | grep -oE '^[[:space:]]*[0-9]+' | awk '{print $1}'
}
pid=$1
while [[ -n "$pid" ]]; do
pid=$(extract_child_pid "$pid")
if [[ -n "$pid" ]]; then
echo "$pid"
fi
done