Skip to content

Commit 2811eb1

Browse files
committed
Keep service around until client exits (ros2#48)
* Keep service around until client exits * use ignore_signal return handler
1 parent 2c9320f commit 2811eb1

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

‎rcl/test/rcl/service_fixture.cpp‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,6 @@ int main(int argc, char ** argv)
113113
}
114114
});
115115

116-
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
117-
118116
// Initialize a response.
119117
example_interfaces__srv__AddTwoInts_Response service_response;
120118
example_interfaces__srv__AddTwoInts_Response__init(&service_response);
@@ -149,6 +147,10 @@ int main(int argc, char ** argv)
149147
return -1;
150148
}
151149
// Our scope exits should take care of fini for everything
150+
// stick around until launch gives us a signal to exit
151+
while (true) {
152+
std::this_thread::sleep_for(std::chrono::milliseconds(1));
153+
}
152154
}
153155
return main_ret;
154156
}

‎rcl/test/rcl/test_two_executables.py.in‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# generated from rcl/test/test_two_executables.py.in
22

33
from launch import LaunchDescriptor
4+
from launch.exit_handler import ignore_signal_exit_handler
45
from launch.exit_handler import primary_exit_handler
56
from launch.launcher import DefaultLauncher
67

@@ -11,11 +12,13 @@ def @TEST_NAME@():
1112
ld.add_process(
1213
cmd=['@TEST_EXECUTABLE1@'],
1314
name='@TEST_EXECUTABLE1_NAME@',
15+
exit_handler=ignore_signal_exit_handler,
1416
)
1517

1618
ld.add_process(
1719
cmd=['@TEST_EXECUTABLE2@', '@TEST_EXECUTABLE1_NAME@'],
1820
name='@TEST_EXECUTABLE2_NAME@',
21+
exit_handler=primary_exit_handler,
1922
)
2023

2124
launcher = DefaultLauncher()

0 commit comments

Comments
 (0)