File tree Expand file tree Collapse file tree 1 file changed +18
-4
lines changed
Expand file tree Collapse file tree 1 file changed +18
-4
lines changed Original file line number Diff line number Diff line change @@ -87,20 +87,34 @@ function start_services {
8787 fi
8888}
8989
90+ function trim {
91+ local str=" $* "
92+
93+ str=" ${str# " ${str%% [![:space:]]* } " } "
94+ str=" ${str% " ${str##* [![:space:]]} " } "
95+
96+ printf ' %s' " $str "
97+ }
98+
9099function pids_list {
91- local pid=" $1 "
92- local pids child_pid
100+ local pid pids child_pid
101+
102+ pid=$( trim " $1 " )
93103
94104 if [[ -z " $pid " ]]; then
95105 return 0
96106 fi
97107
98- echo " $1 "
108+ echo " $pid "
99109 mapfile -t pids < <( ps --ppid " $pid " -o pid | awk ' NR>1' )
100110
101111 if [[ ! 0 -eq " ${# pids[@]} " ]]; then
102112 for child_pid in " ${pids[@]} " ; do
103- pids_list " $child_pid "
113+ child_pid=$( trim " $child_pid " )
114+
115+ if [[ -n " $child_pid " ]]; then
116+ pids_list " $child_pid "
117+ fi
104118 done
105119 fi
106120}
You can’t perform that action at this time.
0 commit comments