From 13bf5beacdfab28eef549ebdf1016da01f0b42e3 Mon Sep 17 00:00:00 2001 From: erling Date: Sat, 1 Feb 2025 01:05:32 +0100 Subject: [PATCH] Also handle SIGTERM gracefully (#2747) Signed-off-by: Erling Rennemo Jellum Signed-off-by: erlingrj Signed-off-by: erling Co-authored-by: Addisu Z. Taddese Co-authored-by: Ian Chen --- src/cmd/cmdsim.rb.in | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/cmd/cmdsim.rb.in b/src/cmd/cmdsim.rb.in index 866dc83ca5..767738ad16 100755 --- a/src/cmd/cmdsim.rb.in +++ b/src/cmd/cmdsim.rb.in @@ -554,9 +554,19 @@ See https://github.com/gazebosim/gz-sim/issues/168 for more info." options['render_engine_gui_api_backend']) end - Signal.trap("INT") { + # Handle SIGINT and SIGTERM signals + def handle_signal(guiPid, serverPid) self.killProcess(guiPid, "Gazebo Sim GUI", 5.0) self.killProcess(serverPid, "Gazebo Sim Server", 5.0) + end + + Signal.trap("INT") { + handle_signal(guiPid, serverPid) + return 1 + } + + Signal.trap("TERM") { + handle_signal(guiPid, serverPid) return 1 }