From 0084d12983f0e1632d85d8936e8a210e0cfd826c Mon Sep 17 00:00:00 2001 From: Tomoya Fujita Date: Sun, 1 Oct 2023 14:28:38 -0700 Subject: [PATCH] catch ExternalShutdownException ros2cli main. (#854) Signed-off-by: Tomoya Fujita --- ros2cli/ros2cli/cli.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ros2cli/ros2cli/cli.py b/ros2cli/ros2cli/cli.py index fb9123054..d3292769a 100644 --- a/ros2cli/ros2cli/cli.py +++ b/ros2cli/ros2cli/cli.py @@ -19,6 +19,8 @@ import signal import sys +from rclpy.executors import ExternalShutdownException + from ros2cli.command import add_subparsers_on_demand @@ -89,6 +91,8 @@ def main(*, script_name='ros2', argv=None, description=None, extension=None): rc = extension.main(parser=parser, args=args) except KeyboardInterrupt: rc = signal.SIGINT + except ExternalShutdownException: + rc = signal.SIGTERM except RuntimeError as e: rc = str(e) return rc