diff --git a/repos/gems/run/depot_autopilot.run b/repos/gems/run/depot_autopilot.run index a5c9378a56..72247b208e 100644 --- a/repos/gems/run/depot_autopilot.run +++ b/repos/gems/run/depot_autopilot.run @@ -112,8 +112,7 @@ proc autopilot_run_genode_until {{wait_for_re forever} {timeout_value 0} {runnin # kill the spawned load process if there is one if {[load_spawn_id] != -1} { - set pid [exp_pid -i [load_spawn_id]] - exec kill -9 $pid + kill_spawned [load_spawn_id] } incr retry -1; @@ -830,7 +829,7 @@ while {1} { if {$run_genode_failed} { # shut-down running system - exec kill -9 [exp_pid -i $serial_id] + kill_spawned $serial_id run_power_off # remember result of last test @@ -902,7 +901,7 @@ while {1} { { # shut-down running system puts "Re-booting to meet maximum number of tests per boot for this platform" - exec kill -9 [exp_pid -i $serial_id] + kill_spawned $serial_id run_power_off # prepare system re-boot diff --git a/tool/run/run b/tool/run/run index b562049538..17693294b8 100755 --- a/tool/run/run +++ b/tool/run/run @@ -307,8 +307,7 @@ proc run_genode_until {{wait_for_re forever} {timeout_value 0} {running_spawn_id # kill the spawned load process if there is one if {[load_spawn_id] != -1} { - set pid [exp_pid -i [load_spawn_id]] - exec kill -9 $pid + kill_spawned [load_spawn_id] } incr retry -1; @@ -329,6 +328,17 @@ proc run_genode_until {{wait_for_re forever} {timeout_value 0} {running_spawn_id } +## +# "Safely" kill spawned process +# +proc kill_spawned {spawn_id} { + set pid [exp_pid -i $spawn_id] + close -i $spawn_id + exec kill -9 $pid + wait -i $spawn_id +} + + ## # Remove color information from output #