diff options
author | noah <noah@656d521f-e311-0410-88e0-e7920216d269> | 2003-04-20 09:48:43 +0000 |
---|---|---|
committer | noah <noah@656d521f-e311-0410-88e0-e7920216d269> | 2003-04-20 09:48:43 +0000 |
commit | 3d24cd590e785f8635866e57ff897d704772c381 (patch) | |
tree | 0d035803091cbf58a3c53303e539f4f0303cfc2e | |
parent | 53153ac888af5c08e5a98446b424b7bd5f165177 (diff) | |
download | pexpect-3d24cd590e785f8635866e57ff897d704772c381.tar.gz |
Always with the fixing isalive()...
git-svn-id: http://pexpect.svn.sourceforge.net/svnroot/pexpect/trunk@178 656d521f-e311-0410-88e0-e7920216d269
-rw-r--r-- | pexpect/pexpect.py | 6 | ||||
-rwxr-xr-x | pexpect/tests/adhoc.py | 15 | ||||
-rw-r--r-- | pexpect/tests/exit667.c | 6 |
3 files changed, 25 insertions, 2 deletions
diff --git a/pexpect/pexpect.py b/pexpect/pexpect.py index 4fa8201..bc9cec5 100644 --- a/pexpect/pexpect.py +++ b/pexpect/pexpect.py @@ -466,7 +466,10 @@ class spawn: try: pid, status = os.waitpid(self.pid, os.WNOHANG) except OSError, e: - return 0 + # Non-Solaris platforms raise an exception. + # This is harmless... I think :-) + print 'XCEPT' + pass # If status is still 0 after two calls to waitpid() then # the process really is alive. This seems to work on all platforms. @@ -479,7 +482,6 @@ class spawn: # # This is dangerous because if I am wrong then this could block. # pid, status = os.waitpid (self.pid, 0) - self.exitstatus = None # I didn't OR this together because I want hooks for debugging. if os.WIFEXITED (status): self.exitstatus = os.WEXITSTATUS(status) diff --git a/pexpect/tests/adhoc.py b/pexpect/tests/adhoc.py new file mode 100755 index 0000000..54b4ad1 --- /dev/null +++ b/pexpect/tests/adhoc.py @@ -0,0 +1,15 @@ +#!/usr/bin/env python +import pexpect +import time + +p = pexpect.spawn ('./a.out') +print p.exitstatus +p.expect (pexpect.EOF) +print p.before +time.sleep(1) +print 'exitstatus:', p.exitstatus +print 'isalive',p.isalive() +print 'exitstatus',p.exitstatus +print 'isalive',p.isalive() +print 'exitstatus',p.exitstatus + diff --git a/pexpect/tests/exit667.c b/pexpect/tests/exit667.c new file mode 100644 index 0000000..f923645 --- /dev/null +++ b/pexpect/tests/exit667.c @@ -0,0 +1,6 @@ +#include <stdio.h> +int main () +{ + printf ("Hello world!\n"); + exit(667); +} |