Reputation: 429
I am running a C program whose exit status is captured by a Python script using the os.system call on a Linux/little-endian machine.
retval=os.system("./cprogexe")
If the exit status is 1, the python variable retval is 256 (reverse byte order). Why is this happening if python does indeed follow the local CPU's byte ordering scheme?
Upvotes: 1
Views: 127
Reputation: 35088
Quoting the docs for os.wait (which the docs for os.system refer to for the return value), the return value is:
a tuple containing its pid and exit status indication: a 16-bit number, whose low byte is the signal number that killed the process, and whose high byte is the exit status (if the signal number is zero)
(emphasis mine). Same on Python 2.
Upvotes: 3