os.system error returns

random832 at fastmail.us random832 at fastmail.us
Fri Jun 12 10:46:36 EDT 2015


For completeness I will note that Windows is completely different. The
plain exit status (1 for typical command failures) appears in the
os.system result rather than a wait-encoded value. And, incidentally, an
MSVC program which calls abort() will return an exit status of 3. A
process that terminates another process with TerminateProcess can set
that process's exit status to an arbitrary 32-bit value. The MSVC exit
function limits the value to one byte, but the raw ExitProcess system
call supports any 32-bit value.

And, just for fun, two versions of "cat" on my system (one supplied with
Git, and one from gnuwin32) return 0x10200 and 0xC000013A respectively
when terminated by Ctrl-C. I think the first is some effort at an
alternate encoding that's compatible with plain exit statuses in the
low-order byte, and the second is the value of STATUS_CONTROL_C_EXIT (an
HRESULT).

I found some information on google suggesting that some unix-alike
layers use an exit status of 0xC00002NN to represent signals (with, once
again, plain exit status being a value of 0x00NN).

All of these values are available as the returned value from os.system.



More information about the Python-list mailing list