Skip to content

Commit d23d206

Browse files
committed
Address peer review comment
Signed-off-by: Ivan Santiago Paunovic <ivanpauno@ekumenlabs.com>
1 parent 6c75ff7 commit d23d206

4 files changed

Lines changed: 30 additions & 2 deletions

File tree

rclcpp/include/rclcpp/utilities.hpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,14 @@ RCLCPP_PUBLIC
9999
bool
100100
signal_handlers_installed();
101101

102+
/// Get the current signal handler options.
103+
/**
104+
* If no signal handler is installed, SignalHandlerOptions::None is returned.
105+
*/
106+
RCLCPP_PUBLIC
107+
SignalHandlerOptions
108+
get_current_signal_handler_options();
109+
102110
/// Uninstall the global signal handler for rclcpp.
103111
/**
104112
* This function does not necessarily need to be called, but can be used to

rclcpp/src/rclcpp/signal_handler.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ SignalHandler::uninstall()
188188
{
189189
set_signal_handler(SIGTERM, old_sigterm_handler_);
190190
}
191-
signal_handlers_options_ = SignalHandlerOptions::All;
191+
signal_handlers_options_ = SignalHandlerOptions::None;
192192
RCLCPP_DEBUG(get_logger(), "SignalHandler::uninstall(): notifying deferred signal handler");
193193
notify_signal_handler();
194194
signal_handler_thread_.join();
@@ -380,3 +380,9 @@ SignalHandler::notify_signal_handler() noexcept
380380
}
381381
#endif
382382
}
383+
384+
rclcpp::SignalHandlerOptions
385+
SignalHandler::get_current_signal_handler_options()
386+
{
387+
return signal_handlers_options_;
388+
}

rclcpp/src/rclcpp/signal_handler.hpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,13 @@ class SignalHandler final
8787
bool
8888
is_installed();
8989

90+
/// Get the current signal handler options.
91+
/**
92+
* If no signal handler is installed, SignalHandlerOptions::None is returned.
93+
*/
94+
rclcpp::SignalHandlerOptions
95+
get_current_signal_handler_options();
96+
9097
private:
9198
/// Signal handler type, platform dependent.
9299
#if defined(RCLCPP_HAS_SIGACTION)
@@ -172,7 +179,7 @@ class SignalHandler final
172179
signal_handler_type
173180
get_old_signal_handler(int signum);
174181

175-
rclcpp::SignalHandlerOptions signal_handlers_options_ = rclcpp::SignalHandlerOptions::All;
182+
rclcpp::SignalHandlerOptions signal_handlers_options_ = rclcpp::SignalHandlerOptions::None;
176183

177184
signal_handler_type old_sigint_handler_;
178185
signal_handler_type old_sigterm_handler_;

rclcpp/src/rclcpp/utilities.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,13 @@ signal_handlers_installed()
5555
return SignalHandler::get_global_signal_handler().is_installed();
5656
}
5757

58+
SignalHandlerOptions
59+
get_current_signal_handler_options()
60+
{
61+
return SignalHandler::get_global_signal_handler().get_current_signal_handler_options();
62+
}
63+
64+
5865
bool
5966
uninstall_signal_handlers()
6067
{

0 commit comments

Comments
 (0)