clean shm

This commit is contained in:
Joe Dong
2022-12-28 17:30:12 +08:00
parent 68662847c5
commit 04e4d4151e
2 changed files with 5 additions and 6 deletions
-6
View File
@@ -153,12 +153,6 @@ install(DIRECTORY
if (BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)
# the following line skips the linter which checks for copyrights
# uncomment the line when a copyright and license is not present in all source files
#set(ament_cmake_copyright_FOUND TRUE)
# the following line skips cpplint (only works in a git repo)
# uncomment the line when this package is not in a git repo
#set(ament_cmake_cpplint_FOUND TRUE)
ament_lint_auto_find_test_dependencies()
endif ()
@@ -35,6 +35,11 @@ OBCameraNodeFactory::OBCameraNodeFactory(const std::string &node_name, const std
OBCameraNodeFactory::~OBCameraNodeFactory() {
is_alive_.store(false);
sem_unlink(DEFAULT_SEM_NAME.c_str());
int shm_id = shmget(DEFAULT_SEM_KEY, 1, 0666 | IPC_CREAT);
if (shm_id != -1) {
shmctl(shm_id, IPC_RMID, nullptr);
}
if (query_thread_ && query_thread_->joinable()) {
query_thread_->join();
}