ros2/rclcpp

LifecycleNode: Take shutdown transition when exiting

Closed this issue · 5 comments

Feature request

Feature description

When a lifecycle node is shut down using CTRL-C, it would be helpful to automatically call the shutdown transition. I would actually consider this "expected behavior".

Currently, the user needs to take care of calling the shutdown transition before exiting, for example through installing their own signal handler. Otherwise, the node is destructed from whichever state it's currently in, potentially leaving the system in an undefined or unsafe state.

Implementation considerations

If the node is currently in another transitioning state, the shutdown request needs to be deferred. If the node is already finalized, the request should be ignored.

@wieset Would you like to propose a PR? We'd be happy to review it.

Any updates on this?
I tired the solution on: https://answers.ros.org/question/343744/ros2-lifecycle-node-how-to-shut-down-cleanly/
But it doesn't work

@Rezenders it would be appreciated if you can try #2450

it has been 4 years, but finally we can close this. #2450 is merged.

Just a follow-up comment.

at this moment, that is a responsibility for user application to manage the state control including shutdown, see more information for #2520 (comment).