diff options
author | Nicholas Chammas <nicholas.chammas@gmail.com> | 2016-01-22 12:00:37 -0500 |
---|---|---|
committer | Nicholas Chammas <nicholas.chammas@gmail.com> | 2016-01-25 17:13:24 -0500 |
commit | 32dbbacc0e4e9747f72920a8c87bfa3f83781c81 (patch) | |
tree | 19fe3857e42ab656c073fcb004b6f714a2fcd60a | |
parent | 524495960dd8898ddd30f7ba37298de51beee773 (diff) | |
download | pexpect-32dbbacc0e4e9747f72920a8c87bfa3f83781c81.tar.gz |
Provide example use of exitstatus and signalstatus
-rw-r--r-- | pexpect/pty_spawn.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/pexpect/pty_spawn.py b/pexpect/pty_spawn.py index ccb38b3..3518cc1 100644 --- a/pexpect/pty_spawn.py +++ b/pexpect/pty_spawn.py @@ -154,7 +154,12 @@ class spawn(SpawnBase): in self.exitstatus or self.signalstatus. If the child exited normally then exitstatus will store the exit return code and signalstatus will be None. If the child was terminated abnormally with a signal then - signalstatus will store the signal value and exitstatus will be None. + signalstatus will store the signal value and exitstatus will be None:: + + child = pexpect.spawn('some_command') + child.close() + print(child.exitstatus, child.signalstatus) + If you need more detail you can also read the self.status member which stores the status returned by os.waitpid. You can interpret this using os.WIFEXITED/os.WEXITSTATUS or os.WIFSIGNALED/os.TERMSIG. |