Skip to content

Jazzy: Ctrl+C does not exit (e.g., sm_atomic_node) — please backport Humble SignalDetector shutdown fixes #654

@henaiguo

Description

@henaiguo

Describe the bug
On ROS 2 Jazzy, pressing Ctrl+C does not fully exit example nodes (e.g., sm_atomic_node) when built with Release/RelWithDebInfo. The first Ctrl+C triggers rclcpp’s signal handler and SMACC2 logs show state exit/cleanup and SignalDetector::pollingLoop() returning, but the process hangs until a second Ctrl+C or an external kill.

To Reproduce
Steps to reproduce the behavior:

  1. Build SMACC2 (branch: jazzy) with colcon.
  2. ros2 run sm_atomic sm_atomic_node
  3. Press Ctrl+C → node does not terminate.

Actual: main loop stops, but the scheduler thread (boost::thread running boost::statechart::fifo_scheduler<>::operator()) keeps running, so the process doesn’t exit. In Release this is very consistent.

It looks like jazzy’s SignalDetector lacks the graceful shutdown behavior that exists on Humble, specifically in:

  • smacc2/include/smacc2/smacc_signal_detector.hpp
  • smacc2/src/smacc2/signal_detector.cpp

The Humble branch registers an on_shutdown callback on the node’s rclcpp Context, and ensures the scheduler is terminated so the thread returns. It also uses context-aware shutdown checks (and avoids spinning while holding the state machine mutex), which prevents deadlocks/hangs on optimized builds.

Request: please sync/backport the Humble fixes into the Jazzy branch (or advise if you’d like a PR). I’m concerned there may be other shutdown/robustness tweaks in Humble that didn’t make it to Jazzy.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions