Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions eplansys_demo/src/corridor_actions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@

#include "rclcpp/rclcpp.hpp"

#include "leave.hpp"

namespace eplansys_demo
{

Expand Down Expand Up @@ -130,6 +132,5 @@ int main(int argc, char ** argv)
}

executor.spin();
rclcpp::shutdown();
return 0;
eplansys_demo::leave(0);
}
47 changes: 47 additions & 0 deletions eplansys_demo/src/leave.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// Copyright 2026 Intelligent Robotics Lab
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef LEAVE_HPP_
#define LEAVE_HPP_

#include <unistd.h>

#include <cstdio>

#include "rclcpp/rclcpp.hpp"

namespace eplansys_demo
{

/// End the process once its work is done, without destroying the performers.
///
/// A performer interrupted by the launch file at the end of a mission
/// segfaulted in about one run in five, after every action had finished. The
/// fault is in the performer's destructor, run from main after
/// rclcpp::shutdown(), while CascadeLifecycleNode frees its activators_state_
/// map through a pointer that is no longer valid; no thread of this process was
/// using the node by then. Nothing is left to do at that point, so the process
/// leaves through _exit and skips the teardown, as plansys2_tests does for its
/// own exit-time fault.
[[noreturn]] inline void leave(int status)
{
rclcpp::shutdown();
std::fflush(stdout);
std::fflush(stderr);
_exit(status);
}

} // namespace eplansys_demo

#endif // LEAVE_HPP_
5 changes: 3 additions & 2 deletions eplansys_demo/src/survey_actions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@

#include "rclcpp/rclcpp.hpp"

#include "leave.hpp"

namespace eplansys_demo
{

Expand Down Expand Up @@ -133,6 +135,5 @@ int main(int argc, char ** argv)
}

executor.spin();
rclcpp::shutdown();
return 0;
eplansys_demo::leave(0);
}
5 changes: 3 additions & 2 deletions eplansys_demo/src/survey_sites_actions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
#include "lifecycle_msgs/msg/transition.hpp"
#include "rclcpp/rclcpp.hpp"

#include "leave.hpp"

namespace eplansys_demo
{

Expand Down Expand Up @@ -136,6 +138,5 @@ int main(int argc, char ** argv)
}

executor.spin();
rclcpp::shutdown();
return 0;
eplansys_demo::leave(0);
}
Loading