Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the SIGTERM handling in the ros2 daemon. #887

Merged
merged 2 commits into from Mar 8, 2024

Conversation

clalancette
Copy link
Contributor

There are 2 fixes needed here:

  1. Make sure to check rclpy.ok() in the overall loop for handling requests. That's because rclpy is handling the signals by default.
  2. Realize that server.handle_request() uses the set timeout as a timeout to select(), essentially. Because of that, we instead set the timeout to a short value (200 milliseconds), and do the overall timeout checking ourselves.

Note that because we are waking up more often, this will cause the ros2 daemon to use more CPU than before. But it should be negligible overall.

This should fix #885

There are 2 fixes needed here:
1.  Make sure to check rclpy.ok() in the overall loop
for handling requests.  That's because rclpy is handling
the signals by default.
2.  Realize that server.handle_request() uses the set
timeout as a timeout to select(), essentially.  Because of
that, we instead set the timeout to a short value (200 milliseconds),
and do the overall timeout checking ourselves.

Note that because we are waking up more often, this will cause
the ros2 daemon to use more CPU than before.  But it should
be negligible overall.

Signed-off-by: Chris Lalancette <clalancette@gmail.com>
Co-authored-by: Scott K Logan <logans@cottsay.net>
Signed-off-by: Chris Lalancette <clalancette@gmail.com>
Copy link
Member

@cottsay cottsay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

@clalancette
Copy link
Contributor Author

CI:

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Windows Build Status

@clalancette
Copy link
Contributor Author

Given that CI is clean, and I think this solves a real problem without too much downside, I'm going to go ahead and merge it in. If we find out that this causes too much problem down the line, we can always extend the timeout; it is just a tradeoff between being reactive and using CPU time.

@clalancette clalancette merged commit b16fb02 into rolling Mar 8, 2024
2 of 3 checks passed
@delete-merged-branch delete-merged-branch bot deleted the clalancette/fix-daemon-sigterm-handler branch March 8, 2024 02:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ROS 2 daemon process ignores SIGTERM
3 participants