Restore old signal handler on shutdown
This commit is contained in:
parent
c15db0b675
commit
be985a652b
1 changed files with 8 additions and 0 deletions
|
@ -167,8 +167,16 @@ rclcpp::utilities::init(int argc, char * argv[])
|
||||||
action.sa_sigaction = ::signal_handler;
|
action.sa_sigaction = ::signal_handler;
|
||||||
action.sa_flags = SA_SIGINFO;
|
action.sa_flags = SA_SIGINFO;
|
||||||
::old_action = set_sigaction(SIGINT, action);
|
::old_action = set_sigaction(SIGINT, action);
|
||||||
|
// Register an on_shutdown hook to restore the old action.
|
||||||
|
rclcpp::utilities::on_shutdown([]() {
|
||||||
|
set_sigaction(SIGINT, ::old_action);
|
||||||
|
});
|
||||||
#else
|
#else
|
||||||
::old_signal_handler = set_signal_handler(SIGINT, ::signal_handler);
|
::old_signal_handler = set_signal_handler(SIGINT, ::signal_handler);
|
||||||
|
// Register an on_shutdown hook to restore the old signal handler.
|
||||||
|
rclcpp::utilities::on_shutdown([]() {
|
||||||
|
set_signal_handler(SIGINT, ::old_signal_handler);
|
||||||
|
});
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue