From 80f63d47efd4d848edff8f44e728b8ea96ae9655 Mon Sep 17 00:00:00 2001 From: Benedek Racz Date: Fri, 24 Jan 2020 10:35:23 +0100 Subject: [PATCH] [FIX] process termination and exitstatus --- tests/test_isalive.py | 4 +++- wexpect/spawn.py | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/test_isalive.py b/tests/test_isalive.py index ca5817f..3e2707e 100644 --- a/tests/test_isalive.py +++ b/tests/test_isalive.py @@ -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() diff --git a/wexpect/spawn.py b/wexpect/spawn.py index 388621e..1376cd0 100644 --- a/wexpect/spawn.py +++ b/wexpect/spawn.py @@ -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