File tree 1 file changed +33
-0
lines changed
1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -243,6 +243,39 @@ filter_file_ok()
243
243
esac
244
244
}
245
245
246
+ process_tree ()
247
+ {
248
+ pid=" ${1:- 0} " ; shift
249
+ pid=" $( expr " $pid " ) "
250
+ test " $pid " -gt 0 || return
251
+
252
+ depth=" ${1:- 0} "
253
+ maxdepth=20
254
+
255
+ printf ' %s\n' " $pid "
256
+
257
+ depth=" $(( depth + 1 )) "
258
+ test " $depth " -ge " $maxdepth " && return
259
+
260
+ last_pid=-1
261
+ while [ " $pid " != " $last_pid " ]; do
262
+ last_pid=" $pid "
263
+ proc_tmp=" $( tempfile_name ' process_tree' ) "
264
+ ps -e -o ppid=,pid= | grep " ^[ 0]*$pid [^0-9]" > " $proc_tmp " || continue
265
+ while read -r child_proc; do
266
+ test -z " $child_proc " && continue
267
+ ORIG_IFS=" $IFS " ; IFS=' '
268
+ set -- $child_proc
269
+ IFS=" $ORIG_IFS "
270
+ test " $# " -ne 2 && continue
271
+ test " $pid " = " $2 " && continue
272
+ pid=" $2 "
273
+ ( process_tree " $pid " " $depth " )
274
+ done < " $proc_tmp "
275
+ rm -f -- " $proc_tmp "
276
+ done
277
+ }
278
+
246
279
#
247
280
# Parse TEST_OPTS
248
281
#
You can’t perform that action at this time.
0 commit comments