Skip to content

Commit

Permalink
Call to rclcpp::shutdown in demos so rclcpp signal handler gets remov…
Browse files Browse the repository at this point in the history
…ed (#162)

* Call to rclcpp::shutdown in demos so rclcpp signal handler gets removed

Otherwise if launch_testing triggers an interrupt while the process is
exiting the process deadlocks when multiple rmw implementions are
supported (and poco is in use). see ros2/rmw_implementation#25

* Apply to other packages too
  • Loading branch information
dhood authored Aug 11, 2017
1 parent 1618ed7 commit 8354081
Show file tree
Hide file tree
Showing 30 changed files with 75 additions and 0 deletions.
3 changes: 3 additions & 0 deletions composition/src/api_composition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,5 +159,8 @@ int main(int argc, char * argv[])
exec.remove_node(node);
}
nodes.clear();

rclcpp::shutdown();

return 0;
}
3 changes: 3 additions & 0 deletions composition/src/dlopen_composition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,8 @@ int main(int argc, char * argv[])
exec.remove_node(node);
}
nodes.clear();

rclcpp::shutdown();

return 0;
}
3 changes: 3 additions & 0 deletions composition/src/linktime_composition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,8 @@ int main(int argc, char * argv[])
exec.remove_node(node);
}
nodes.clear();

rclcpp::shutdown();

return 0;
}
3 changes: 3 additions & 0 deletions composition/src/manual_composition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,8 @@ int main(int argc, char * argv[])
// spin will block until work comes in, execute work as it becomes available, and keep blocking.
// It will only be interrupted by Ctrl-C.
exec.spin();

rclcpp::shutdown();

return 0;
}
2 changes: 2 additions & 0 deletions demo_nodes_cpp/src/parameters/list_parameters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,7 @@ int main(int argc, char ** argv)
std::cout << "Parameter prefix: " << prefix << std::endl;
}

rclcpp::shutdown();

return 0;
}
2 changes: 2 additions & 0 deletions demo_nodes_cpp/src/parameters/list_parameters_async.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,7 @@ int main(int argc, char ** argv)
std::cout << "Parameter prefix: " << prefix << std::endl;
}

rclcpp::shutdown();

return 0;
}
2 changes: 2 additions & 0 deletions demo_nodes_cpp/src/parameters/parameter_events.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,7 @@ int main(int argc, char ** argv)

rclcpp::spin_some(node);

rclcpp::shutdown();

return 0;
}
2 changes: 2 additions & 0 deletions demo_nodes_cpp/src/parameters/parameter_events_async.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,5 +73,7 @@ int main(int argc, char ** argv)

rclcpp::spin_some(node);

rclcpp::shutdown();

return 0;
}
2 changes: 2 additions & 0 deletions demo_nodes_cpp/src/parameters/parameter_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,7 @@ int main(int argc, char ** argv)

rclcpp::spin(node);

rclcpp::shutdown();

return 0;
}
3 changes: 3 additions & 0 deletions demo_nodes_cpp/src/parameters/ros2param.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,5 +164,8 @@ int main(int argc, char ** argv)
fprintf(stderr, "%s\n", USAGE);
return 1;
}

rclcpp::shutdown();

return 0;
}
2 changes: 2 additions & 0 deletions demo_nodes_cpp/src/parameters/set_and_get_parameters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,7 @@ int main(int argc, char ** argv)
parameter.value_to_string() << std::endl;
}

rclcpp::shutdown();

return 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,7 @@ int main(int argc, char ** argv)
parameter.value_to_string() << std::endl;
}

rclcpp::shutdown();

return 0;
}
3 changes: 3 additions & 0 deletions dummy_robot/dummy_map_server/src/dummy_map_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,8 @@ int main(int argc, char * argv[])
rclcpp::spin_some(node);
loop_rate.sleep();
}

rclcpp::shutdown();

return 0;
}
3 changes: 3 additions & 0 deletions dummy_robot/dummy_sensors/src/dummy_joint_states.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,8 @@ int main(int argc, char * argv[])
rclcpp::spin_some(node);
loop_rate.sleep();
}

rclcpp::shutdown();

return 0;
}
3 changes: 3 additions & 0 deletions dummy_robot/dummy_sensors/src/dummy_laser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,5 +87,8 @@ int main(int argc, char * argv[])
rclcpp::spin_some(node);
loop_rate.sleep();
}

rclcpp::shutdown();

return 0;
}
2 changes: 2 additions & 0 deletions image_tools/src/cam2image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,5 +210,7 @@ int main(int argc, char * argv[])
loop_rate.sleep();
}

rclcpp::shutdown();

return 0;
}
2 changes: 2 additions & 0 deletions image_tools/src/showimage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,5 +143,7 @@ int main(int argc, char * argv[])

rclcpp::spin(node);

rclcpp::shutdown();

return 0;
}
3 changes: 3 additions & 0 deletions intra_process_demo/src/cyclic_pipeline/cyclic_pipeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,5 +81,8 @@ int main(int argc, char * argv[])
executor.add_node(pipe1);
executor.add_node(pipe2);
executor.spin();

rclcpp::shutdown();

return 0;
}
3 changes: 3 additions & 0 deletions intra_process_demo/src/image_pipeline/camera_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,8 @@ int main(int argc, char ** argv)
}

rclcpp::spin(camera_node);

rclcpp::shutdown();

return 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,8 @@ int main(int argc, char * argv[])
executor.add_node(image_view_node);

executor.spin();

rclcpp::shutdown();

return 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,8 @@ int main(int argc, char * argv[])
executor.add_node(image_view_node2);

executor.spin();

rclcpp::shutdown();

return 0;
}
3 changes: 3 additions & 0 deletions intra_process_demo/src/image_pipeline/image_view_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,8 @@ int main(int argc, char ** argv)
rclcpp::init(argc, argv);
auto image_view_node = std::make_shared<ImageViewNode>("watermarked_image");
rclcpp::spin(image_view_node);

rclcpp::shutdown();

return 0;
}
3 changes: 3 additions & 0 deletions intra_process_demo/src/image_pipeline/watermark_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,8 @@ int main(int argc, char ** argv)
auto watermark_node =
std::make_shared<WatermarkNode>("image", "watermarked_image", "Hello world!");
rclcpp::spin(watermark_node);

rclcpp::shutdown();

return 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -83,5 +83,8 @@ int main(int argc, char * argv[])
executor.add_node(producer);
executor.add_node(consumer);
executor.spin();

rclcpp::shutdown();

return 0;
}
2 changes: 2 additions & 0 deletions lifecycle/src/lifecycle_listener.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,5 +78,7 @@ int main(int argc, char ** argv)
auto lc_listener = std::make_shared<LifecycleListener>("lc_listener");
rclcpp::spin(lc_listener);

rclcpp::shutdown();

return 0;
}
2 changes: 2 additions & 0 deletions lifecycle/src/lifecycle_service_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -295,5 +295,7 @@ int main(int argc, char ** argv)
std::bind(callee_script, lc_client));
exe.spin_until_future_complete(script);

rclcpp::shutdown();

return 0;
}
2 changes: 2 additions & 0 deletions lifecycle/src/lifecycle_talker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -266,5 +266,7 @@ int main(int argc, char * argv[])

exe.spin();

rclcpp::shutdown();

return 0;
}
2 changes: 2 additions & 0 deletions pendulum_control/src/pendulum_demo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -298,4 +298,6 @@ int main(int argc, char * argv[])

printf("PendulumMotor received %lu messages\n", pendulum_motor->messages_received);
printf("PendulumController received %lu messages\n", pendulum_controller->messages_received);

rclcpp::shutdown();
}
2 changes: 2 additions & 0 deletions pendulum_control/src/pendulum_logger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,6 @@ int main(int argc, char * argv[])
printf("Logger node initialized.\n");
rclcpp::spin(logger_node);
fstream.close();

rclcpp::shutdown();
}
2 changes: 2 additions & 0 deletions pendulum_control/src/pendulum_teleop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,6 @@ int main(int argc, char * argv[])
pub->publish(msg);
rclcpp::spin_some(teleop_node);
std::cout << "Teleop node exited." << std::endl;

rclcpp::shutdown();
}

0 comments on commit 8354081

Please sign in to comment.