diff --git a/IPython/utils/_process_posix.py b/IPython/utils/_process_posix.py index d6d53ef..9c6054f 100644 --- a/IPython/utils/_process_posix.py +++ b/IPython/utils/_process_posix.py @@ -187,7 +187,16 @@ 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 + # number. + # on Linux, sh returns 128+n for signals terminating child processes on Linux + # on BSD (OS X), the signal code is set instead + 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