[FIX] process termination and exitstatus

This commit is contained in:
Benedek Racz 2020-01-24 10:35:23 +01:00
parent 51426bc41d
commit 80f63d47ef
2 changed files with 5 additions and 2 deletions

View File

@ -52,6 +52,7 @@ class IsAliveTestCase(PexpectTestCase.PexpectTestCase):
def test_expect_isalive_dead_after_normal_termination (self):
p = wexpect.spawn('ls', timeout=15)
p.expect(wexpect.EOF)
time.sleep(.5)
assert not p.isalive()
def test_expect_isalive_dead_after_SIGHUP(self):
@ -77,7 +78,7 @@ class IsAliveTestCase(PexpectTestCase.PexpectTestCase):
def test_expect_isalive_dead_after_SIGKILL(self):
p = wexpect.spawn('cat', timeout=5)
assert p.isalive()
p.kill(9)
p.kill()
p.expect(wexpect.EOF)
assert not p.isalive()
@ -99,6 +100,7 @@ class IsAliveTestCase(PexpectTestCase.PexpectTestCase):
assert p.isalive()
p.sendeof()
p.expect(wexpect.EOF)
time.sleep(.5)
assert not p.isalive()
assert not p.isalive()

View File

@ -441,7 +441,8 @@ class SpawnBase:
if child:
self.child_process.wait()
if console:
self.console_process.wait()
self.exitstatus = self.console_process.wait()
return self.exitstatus
def read (self, size = -1): # File-like object.
"""This reads at most "size" bytes from the file (less if the read hits