Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use signalstatus if exit status is undefined #4458

Merged
merged 2 commits into from Oct 29, 2013
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions IPython/utils/_process_posix.py
Expand Up @@ -188,6 +188,13 @@ def system(self, cmd):
# 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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should tweak this comment a bit. Something like sh returns 128+n for signals terminating child processes on Linux; on Macs, it passes the complete exit code back to pexpect (that's my understanding of it at present).

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
Expand Down