[IPython-dev] system_raw exit code

Jason Grout jason-sage at creativetrax.com
Tue Aug 6 14:31:17 EDT 2013

I'm working on getting Sage updated to 1.0 RC1, and ran into some 
problems with interpreting exit codes from the InteractiveShell's 
system_raw command.

According to 
if (and only if) the exit code is nonzero, the signal part of the status 
code is overwritten with the exit code.  If the exit code is 0, then the 
signal information in the low bit is allowed to persist as the 'exit 

We're trying to interpret the _exit_code variable using the various 
official os.WIFEXITED, os.WSTOPSIG, etc. functions.    It works fine if 
the exit code was 0, but fails when the exit code is nonzero.

Can we either not touch the exit code in system_raw (and rely on the 
user to use the os.W* functions to interpret it), or change it to the 
exit status all the time, perhaps with something like:

if os.WIFEXITED(ec):
     self.user_ns['_exit_code'] = os.WEXITSTATUS(ec)
     self.user_ns['_exit_code'] = None

Perhaps since the variable is called _exit_code instead of _exit_status, 
it makes more sense to not touch the exit code and delete the "if ec > 
255: ec >>= 8" code.



More information about the IPython-dev mailing list