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/5RPZPH4FSigned-off-by: NAmador Pahim <apahim@redhat.com>
Showing
想要评论请 注册 或 登录