-
- Downloads
Fix SIGINT/SIGTERM
The SIGINT/SIGTERM handlers are currently broken. When we execute a SIMPLE TEST, which ignores SIGINT/SIGTERM, the test process will not finish on SIGINT/SIGTERM, becoming orphan. Reproducer:: $ cat /tmp/test.py #!/usr/bin/env python import signal import time if __name__ == "__main__": signal.signal(signal.SIGINT, signal.SIG_IGN) signal.signal(signal.SIGTERM, signal.SIG_IGN) signal.signal(signal.SIGQUIT, signal.SIG_IGN) while True: time.sleep(0.1) $ avocado run /tmp/test.py Then play with `Ctrl+C` (once and twice), with `kill -2 <pid>` and `kill <pid>`. Check if Avocado hangs or whether any process is left behind. Also, the only test we have for those cases is supposed to catch the issue with SIGINT (test_interrupt.InterruptTest.test_badly_behaved), but it's not really working. This patch fixes the SIGINT/SIGTERM actions, as follows: - When a SIGINT is sent to the main main process, we send the same SIGINT to all the children hope for the best. This reproduces the behaviour on Ctrl+C. - On a second SIGINT (after the 2s ignore period), meaning process is still running, we send a SIGKILL to all the children. - When a SIGTERM is sent to the main process, we now send a SIGKILL to all the children (instead of a SIGTERM), so any subprocess ignoring SIGTERM will be terminated anyway. Reference: https://trello.com/c/5RPZPH4F Signed-off-by:Amador Pahim <apahim@redhat.com>
Showing
- avocado/core/app.py 1 addition, 1 deletionavocado/core/app.py
- avocado/core/runner.py 2 additions, 1 deletionavocado/core/runner.py
- docs/source/ReferenceGuide.rst 30 additions, 0 deletionsdocs/source/ReferenceGuide.rst
- selftests/functional/test_interrupt.py 189 additions, 96 deletionsselftests/functional/test_interrupt.py
Loading
Please register or sign in to comment