make getpeername() return the original socket address which before it was intercepted
[hband-tools.git] / user-tools / descpids
blobdafa97429ce7b1c273d39c3d272d052066f0c2a2
1 #!/bin/bash
3 true <<EOF
4 =pod
6 =head1 NAME
8 descpids - List all descendant process PIDs of the given process(es)
10 =cut
12 EOF
15 declare -A all_descendants=()
16 declare -A all_ancestors=()
18 for ancestor in "$@"
20 all_ancestors[$ancestor]=''
21 done
23 while [ "${#all_ancestors[@]}" -gt 0 ]
25 for ancestor in "${!all_ancestors[@]}"
27 for descendant in `pgrep -P "$ancestor"`
29 all_descendants[$descendant]=''
30 all_ancestors[$descendant]=''
31 done
32 unset all_ancestors[$ancestor]
33 done
34 done
36 echo "${!all_descendants[@]}"