Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 2febb73

Browse files
committedDec 22, 2021
Revert "Shutdown asynchronously when sigint is received (#844)"
This reverts commit 77949d2.
1 parent 6e54450 commit 2febb73

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed
 

‎rclpy/src/rclpy/signal_handler.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ std::thread g_deferred_signal_handling_thread;
5757

5858
// relying on python GIL for safety
5959
std::atomic<bool> g_signal_handler_installed = false;
60+
std::atomic<bool> g_is_sigterm;
6061

6162
void
6263
notify_signal_handler() noexcept
@@ -140,7 +141,9 @@ setup_deferred_signal_handler()
140141
wait_for_signal();
141142
if (g_signal_handler_installed.load()) {
142143
trigger_guard_conditions();
143-
rclpy::shutdown_contexts();
144+
if (g_is_sigterm.exchange(false)) {
145+
rclpy::shutdown_contexts();
146+
}
144147
}
145148
}
146149
});
@@ -325,6 +328,7 @@ DEFINE_SIGNAL_HANDLER(rclpy_sigterm_handler)
325328
// Try to unregister again.
326329
unregister_sigint_signal_handler();
327330
} else {
331+
g_is_sigterm.exchange(true);
328332
notify_signal_handler();
329333
}
330334
}

0 commit comments

Comments
 (0)
Please sign in to comment.