diff --git a/rclcpp/minimal_subscriber/static_wait_set.cpp b/rclcpp/minimal_subscriber/static_wait_set.cpp index 5842ecc3..52e7bcc1 100644 --- a/rclcpp/minimal_subscriber/static_wait_set.cpp +++ b/rclcpp/minimal_subscriber/static_wait_set.cpp @@ -49,7 +49,9 @@ class MinimalSubscriber : public rclcpp::Node ~MinimalSubscriber() { - thread_.join(); + if (thread_.joinable()) { + thread_.join(); + } } void spin_wait_set() diff --git a/rclcpp/minimal_subscriber/wait_set.cpp b/rclcpp/minimal_subscriber/wait_set.cpp index 380323e1..fb1213a2 100644 --- a/rclcpp/minimal_subscriber/wait_set.cpp +++ b/rclcpp/minimal_subscriber/wait_set.cpp @@ -46,7 +46,9 @@ class MinimalSubscriber : public rclcpp::Node ~MinimalSubscriber() { - thread_.join(); + if (thread_.joinable()) { + thread_.join(); + } } void spin_wait_set() diff --git a/rclcpp/wait_set/include/wait_set/listener.hpp b/rclcpp/wait_set/include/wait_set/listener.hpp index 6ae55491..f4d9d7c5 100644 --- a/rclcpp/wait_set/include/wait_set/listener.hpp +++ b/rclcpp/wait_set/include/wait_set/listener.hpp @@ -23,7 +23,7 @@ class Listener : public rclcpp::Node { public: WAIT_SET_PUBLIC explicit Listener(rclcpp::NodeOptions options); - WAIT_SET_PUBLIC ~Listener(); + WAIT_SET_PUBLIC ~Listener() override; private: void spin_wait_set(); diff --git a/rclcpp/wait_set/src/listener.cpp b/rclcpp/wait_set/src/listener.cpp index 52cec13a..e56bda06 100644 --- a/rclcpp/wait_set/src/listener.cpp +++ b/rclcpp/wait_set/src/listener.cpp @@ -51,7 +51,9 @@ Listener::Listener(rclcpp::NodeOptions options) Listener::~Listener() { - thread_.join(); + if (thread_.joinable()) { + thread_.join(); + } } void Listener::spin_wait_set()