Repository navigation
fix(gateway): defer a shutdown signal until startup is done - #734
Merged
Merged
Conversation
bburda
force-pushed
the
fix/gateway-startup-signal
branch
from
October 19, 2026 12:58
71ccbc3 to
fcf48bb
Compare
bburda
force-pushed
the
fix/gateway-startup-signal
branch
from
October 19, 2026 15:19
fcf48bb to
de076e7
Compare
mfaferek93
reviewed
Oct 19, 2026
bburda
force-pushed
the
fix/gateway-startup-signal
branch
from
October 20, 2026 10:54
de076e7 to
7a8d189
Compare
bburda
force-pushed
the
fix/gateway-startup-signal
branch
from
October 20, 2026 12:47
7a8d189 to
7d126e0
Compare
bburda
force-pushed
the
fix/gateway-startup-signal
branch
from
October 20, 2026 12:55
7d126e0 to
50d77dd
Compare
bburda
force-pushed
the
fix/gateway-startup-signal
branch
from
October 20, 2026 20:02
50d77dd to
f6dbf30
Compare
A SIGINT or SIGTERM during startup shut the rclcpp context down while main was still building the gateway. The next rcl call threw and main exited 1, or the gateway aborted: NodeGraph::get_graph_event clears its graph listener flag before add_node throws, and ~NodeGraph then throws NodeNotFoundError. main now blocks both signals before rclcpp::init, which runs with SignalHandlerOptions::None, and keeps them blocked until startup is done. It then installs rclcpp's handlers and unblocks, so a signal sent meanwhile shuts the context down at that point and the normal teardown runs. Threads that start during startup keep the blocked mask, and exec keeps it too. DefaultScriptProvider resets the mask in the forked child, so the stop action ends a script with SIGTERM. The OPC-UA startup sweep runs during construction, and it stopped only when rclcpp::ok() turned false. It now also reads a pending SIGINT or SIGTERM with sigpending(), so a stop still ends the sweep, and the gateway exits once startup is done. test_scripts_api checks that stop ends the script process. test_opcua_startup_sweep_signal sends each signal during a sweep against a silent listener on port 4840.
bburda
force-pushed
the
fix/gateway-startup-signal
branch
from
October 21, 2026 07:11
f6dbf30 to
d743377
Compare
mfaferek93
approved these changes
Oct 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request
Summary
A SIGINT or SIGTERM that arrives while the gateway is still starting ends it with exit code 0, through the same teardown as a shutdown after startup.
mainblocks SIGINT and SIGTERM beforerclcpp::init(withSignalHandlerOptions::None) and keeps them blocked until startup is done. It then installs rclcpp's handlers and unblocks, so a signal sent meanwhile is delivered at that point, the context shuts down, spin returns at once and the explicit teardown runs.NodeGraph::get_graph_eventclears its listener flag beforeadd_nodethrows, and the node's destructor then throwsNodeNotFoundError.DefaultScriptProviderresets the mask in the forked child, sostopends a script with SIGTERM.sigpending(), so a stop still ends the sweep, and the gateway exits once startup is done.Issue
Type
Testing
./scripts/test.sh integ --packages-select ros2_medkit_integration_testsrunstest_gateway_startup_signal. It starts the realgateway_noderepeatedly, signals it 0 to 10 ms after each of five startup log lines and once it is spinning, and expects exit code 0 every time.test_scripts_apichecks thatstopends the script process../scripts/test.sh integ --packages-select ros2_medkit_opcuarunstest_opcua_startup_sweep_signal, which sends each signal during a startup sweep against a silent listener on port 4840.Checklist