Skip to content

Commit

Permalink
Replace signal.default_int_handler with dummy lambda handler
Browse files Browse the repository at this point in the history
Signed-off-by: Cian Donovan <[email protected]>
  • Loading branch information
ciandonovan committed Jun 20, 2023
1 parent 708f098 commit 6b1d541
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
2 changes: 1 addition & 1 deletion launch/launch/utilities/signal_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ def handle(
:return: previous handler if any, otherwise None
"""
signum = signal.Signals(signum)
signal.signal(signum, signal.default_int_handler)
signal.signal(signum, lambda signal, frame: None)
if handler is not None:
if not callable(handler):
raise ValueError('signal handler must be a callable')
Expand Down
6 changes: 2 additions & 4 deletions launch/test/launch/utilities/test_signal_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,10 @@ def _wrapper(*args, **kwargs):
handlers = {}
try:
for s in signals:
handlers[s] = signal.signal(s, signal.default_int_handler)
handlers[s] = signal.signal(s, lambda signal, frame: None)
return func(*args, **kwargs)
except KeyboardInterrupt:
pass
finally:
assert all(signal.signal(s, h) is signal.default_int_handler
assert all(signal.signal(s, h) is (lambda signal, frame: None)
for s, h in handlers.items())
return _wrapper

Expand Down

0 comments on commit 6b1d541

Please sign in to comment.