You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
Seems reasonable to me, but it is a significant change in behavior which might affect how things with with say launch right now. So it would need to be thoroughly tested.
Activity
wjwwood commentedon Jul 1, 2021
Seems reasonable to me, but it is a significant change in behavior which might affect how things with with say launch right now. So it would need to be thoroughly tested.
@ros2/team for feedback.
emersonknapp commentedon Jul 2, 2021
We could also consider default to false, in which case the default behavior would not change. Though I think I'd prefer to default to true.
clalancette commentedon Jul 6, 2021
👍 to handling SIGTERM as well, though I agree with William that it needs thorough testing. Messing with the signal handlers is always fragile.