From 9e11b793794b6059e183f082853a952f7efdc158 2013-10-29 23:19:16 From: MinRK Date: 2013-10-29 23:19:16 Subject: [PATCH] use signalstatus if exit status is undefined fixes failing test_exit_code_signal on OS X --- diff --git a/IPython/utils/_process_posix.py b/IPython/utils/_process_posix.py index d6d53ef..4e778f2 100644 --- a/IPython/utils/_process_posix.py +++ b/IPython/utils/_process_posix.py @@ -188,6 +188,13 @@ class ProcessHandler(object): # We follow the subprocess pattern, returning either the exit status # as a positive number, or the terminating signal as a negative # number. sh returns 128+n for signals + if child.exitstatus is None: + # on WIFSIGNALED, pexpect sets signalstatus, leaving exitstatus=None + if child.signalstatus is None: + # this condition may never occur, + # but let's be certain we always return an integer. + return 0 + return -child.signalstatus if child.exitstatus > 128: return -(child.exitstatus - 128) return child.exitstatus