Skip to content

Commit 9e88282

Browse files
authored
[Spawner] Block further SIGINTs with unload_on_kill option (#3075) (#3127)
1 parent 0485109 commit 9e88282

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

controller_manager/controller_manager/spawner.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import argparse
1717
import errno
1818
import os
19+
import signal
1920
import sys
2021
import time
2122
import warnings
@@ -310,6 +311,11 @@ def main(args=None):
310311
while True:
311312
time.sleep(1)
312313
except KeyboardInterrupt:
314+
# Ignore further SIGINTs so a second signal cannot interrupt cleanup.
315+
# Without this, a signal delivered while rclpy's C extension returns to
316+
# Python can raise a second KeyboardInterrupt inside the except block,
317+
# skipping the deactivate/unload calls and leaving controllers loaded.
318+
signal.signal(signal.SIGINT, signal.SIG_IGN)
313319
if not args.stopped and not args.inactive:
314320
node.get_logger().info("Interrupt captured, deactivating and unloading controller")
315321
# TODO(saikishor) we might have an issue in future, if any of these controllers is in chained mode

0 commit comments

Comments
 (0)