diff options
author | Thomas Kluyver <takowl@gmail.com> | 2013-10-21 12:50:11 -0700 |
---|---|---|
committer | Thomas Kluyver <takowl@gmail.com> | 2013-10-21 12:50:11 -0700 |
commit | 8ed644d85fcfa18cc034e884f547696116e54771 (patch) | |
tree | 1d7cb1de48b83178101a075e7493d9881ae4f879 | |
parent | dec517d98223cb1c6b04fa06a8da4f69827a8bbd (diff) | |
download | pexpect-git-8ed644d85fcfa18cc034e884f547696116e54771.tar.gz |
Test forcing termination (SIGKILL)
-rwxr-xr-x | tests/needs_kill.py | 13 | ||||
-rwxr-xr-x | tests/test_isalive.py | 7 |
2 files changed, 19 insertions, 1 deletions
diff --git a/tests/needs_kill.py b/tests/needs_kill.py new file mode 100755 index 0000000..810236b --- /dev/null +++ b/tests/needs_kill.py @@ -0,0 +1,13 @@ +#!/usr/bin/env python +"""This script can only be killed by SIGKILL.""" +import signal, time + +# Ignore interrupt, hangup and continue signals - only SIGKILL will work +signal.signal(signal.SIGINT, signal.SIG_IGN) +signal.signal(signal.SIGHUP, signal.SIG_IGN) +signal.signal(signal.SIGCONT, signal.SIG_IGN) + +print('READY') +while True: + time.sleep(10) +
\ No newline at end of file diff --git a/tests/test_isalive.py b/tests/test_isalive.py index 7810e2e..5386bac 100755 --- a/tests/test_isalive.py +++ b/tests/test_isalive.py @@ -90,9 +90,14 @@ class IsAliveTestCase(PexpectTestCase.PexpectTestCase): if p.isalive(): self.fail ('Child process is not dead. It should be.') + def test_forced_terminate(self): + p = pexpect.spawn(sys.executable, ['needs_kill.py']) + p.expect('READY') + res = p.terminate(force=True) + assert res, res + ### Some platforms allow this. Some reset status after call to waitpid. def test_expect_isalive_consistent_multiple_calls (self): - '''This tests that multiple calls to isalive() return same value. ''' |