Skip to content

Commit

Permalink
Shutdown asynchronously when sigint is received (#844)
Browse files Browse the repository at this point in the history
Signed-off-by: Ivan Santiago Paunovic <ivanpauno@ekumenlabs.com>
  • Loading branch information
ivanpauno authored Nov 10, 2021
1 parent f2cb25b commit 77949d2
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions rclpy/src/rclpy/signal_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ std::thread g_deferred_signal_handling_thread;

// relying on python GIL for safety
std::atomic<bool> g_signal_handler_installed = false;
std::atomic<bool> g_is_sigterm;

void
notify_signal_handler() noexcept
Expand Down Expand Up @@ -141,9 +140,7 @@ setup_deferred_signal_handler()
wait_for_signal();
if (g_signal_handler_installed.load()) {
trigger_guard_conditions();
if (g_is_sigterm.exchange(false)) {
rclpy::shutdown_contexts();
}
rclpy::shutdown_contexts();
}
}
});
Expand Down Expand Up @@ -328,7 +325,6 @@ DEFINE_SIGNAL_HANDLER(rclpy_sigterm_handler)
// Try to unregister again.
unregister_sigint_signal_handler();
} else {
g_is_sigterm.exchange(true);
notify_signal_handler();
}
}
Expand Down

0 comments on commit 77949d2

Please sign in to comment.