-
Notifications
You must be signed in to change notification settings - Fork 522
Description
Feature request
Feature description
The rclcpp Context shuts down gracefully on a SIGINT, which is generally received via a Ctrl+C interaction. However, another reasonable way on Linux to try to shut down processes is via a SIGTERM - according to GNU Documentation:
The SIGTERM signal is a generic signal used to cause program termination. Unlike SIGKILL, this signal can be blocked, handled, and ignored. It is the normal way to politely ask a program to terminate.
It seems reasonable to me to have rclcpp generate a clean shutdown on SIGTERM by default. This could be another InitOptions member like shutdown_on_sigint, defaulting to true.
For context - I am trying to support a use case where rosbag2 recording processes are controlled via SIGTERM. In order for the recording to finish cleanly and generate all the metadata, it needs to have a graceful shutdown rather than immediate termination. I can handle this at the rosbag2 level, but given the preexisting SIGINT handling in the ros2 client, it makes sense to me to extend that handling to support this case.
Implementation considerations
Should be pretty easy, install signal handlers the same way we do for SIGINT.