From 854489e0f4d53b1ed9524cb74e7b861b03bd2f7b Mon Sep 17 00:00:00 2001 From: FARHANG Date: Fri, 13 Dec 2024 19:07:42 -0500 Subject: [PATCH] Add cleanup function for SITL Gazebo on macOS --- ROMFS/px4fmu_common/init.d-posix/px4-rc.simulator | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/ROMFS/px4fmu_common/init.d-posix/px4-rc.simulator b/ROMFS/px4fmu_common/init.d-posix/px4-rc.simulator index 90e86aa6880e..0c2549c6633c 100644 --- a/ROMFS/px4fmu_common/init.d-posix/px4-rc.simulator +++ b/ROMFS/px4fmu_common/init.d-posix/px4-rc.simulator @@ -1,6 +1,16 @@ #!/bin/sh # shellcheck disable=SC2154 +# Function to handle cleanup +if [ "$(uname)" = "Darwin" ]; then + cleanup() { + echo "INFO [init] Cleaning up on macOS..." + pkill -f "gz sim" || true # Ignore errors if no process is found + trap - INT TERM # Clear the trap to prevent re-triggering + exit 0 # Exit gracefully + } +fi + # Simulator IMU data provided at 250 Hz param set-default IMU_INTEG_RATE 250