@@ -57,7 +57,7 @@ main() {
5757 #
5858 # Restart validator for multithreaded test
5959 #
60- cleanup $surfpool_pid
60+ cleanup " $surfpool_pid "
6161 surfpool_pid=$( start_surfpool)
6262
6363 #
@@ -74,7 +74,7 @@ main() {
7474 #
7575 # Restart validator for async test
7676 #
77- cleanup $surfpool_pid
77+ cleanup " $surfpool_pid "
7878 surfpool_pid=$( start_surfpool)
7979
8080 #
@@ -91,23 +91,21 @@ main() {
9191}
9292
9393cleanup () {
94- local surfpool_pid=${1:- }
95-
96- # Kill specific surfpool process if PID provided
97- if [ -n " $surfpool_pid " ]; then
94+ local surfpool_pid=$1
95+
96+ if [ -n " ${surfpool_pid:- } " ]; then
9897 echo " Killing surfpool process with PID: $surfpool_pid "
9998 kill " $surfpool_pid " 2> /dev/null || true
100- # Give it a moment to shutdown gracefully
10199 sleep 1
102- # Force kill if still running
103100 kill -9 " $surfpool_pid " 2> /dev/null || true
104101 fi
105-
106- # Kill any remaining child processes
102+
103+ # Kill remaining children
107104 pkill -P $$ || true
108105 wait || true
109106}
110107
108+
111109trap_add () {
112110 trap_add_cmd=$1 ; shift || fatal " ${FUNCNAME} usage error"
113111 for trap_add_name in " $@ " ; do
@@ -152,5 +150,5 @@ start_surfpool() {
152150}
153151
154152declare -f -t trap_add
155- trap_add ' cleanup' EXIT
153+ trap ' cleanup' EXIT
156154main
0 commit comments