Class UnixSignalHandler

Inheritance Relationships

Base Type

  • public QObject

Class Documentation

class UnixSignalHandler : public QObject

Bridges POSIX SIGINT/SIGTERM delivery into the Qt event loop.

rclcpp::init() installs its own SIGINT handler that shuts down the ROS context, but has no way to stop QApplication::exec(), so the GUI event loop (and thus the process) never exits on Ctrl+C. This class uses the standard Qt self-pipe/socketpair pattern: the async-signal-safe handler only writes a byte to a socket, and a QSocketNotifier on the Qt thread reacts to that by calling QCoreApplication::quit(), which lets the process shut down cleanly instead of relying on an external supervisor to escalate to SIGTERM/SIGKILL after a timeout.

Public Functions

explicit UnixSignalHandler(QObject *parent = nullptr)
void setup()

Public Static Functions

static void intSignalHandler(int unused)
static void termSignalHandler(int unused)