Skip to content

Shutdown cleanly on SIGTERM #1704

@emersonknapp

Description

@emersonknapp

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions