subprocess returncode is masked

Emmanuel emmanuel.gaudin at pragmadev.com
Tue Dec 29 05:35:50 EST 2009


MRAB wrote :
> Emmanuel wrote:
>> I'm using Python 2.6 and the new subprocess module to get the exit 
>> value of an external executable. It appears the return value given by
>>  wait() or poll() operations is masked under Unix: I only get the 
>> lower 8 bits. So an exit value of 0x0402 in the C program will be seen 
>> as 0x02 in Python. And this does not happen on Windows... Any idea why 
>> that is ?
>>
> I believe that in Unix the exit code is indeed limited to 8 bits.
Looks like you're right but the info is difficult to find since it is 
implementation dependent. I finally found it on 
http://en.wikipedia.org/wiki/Exit_status. This is very confusing because 
the parameter type of the exit function is an int ?!



More information about the Python-list mailing list