Add: if a third partyProgramThe return value is a Boolean value. OS. system converts true to 1, false to 0, and returns the result.
The forwarding is as follows:
I remember a friend on the python.cn email list asked me about the abnormal return value of OS. System. I met it again today, so let's summarize it.
Problem:
/Bin/xxx. py is a program with a return code of 1.
When the python program uses OS. system (". /bin/xxx. in this way, the OS. the returned value of system becomes 256, that is, 0 × 100. Instead of returning 1 normally.
Solution:
Found the document
OS. System () returns:
On UNIX, the return value is the exit status of the process encoded in
The format specified for wait ().
OS. Wait () returns the following:
A 16-bit number, whose low byte is the signal number that killed
Process, and whose high byte is the exit status (if the signal number
Is zero );
The return value of OS. system is not the result returned by the execution program. It is a 16-bit number, and its high position is the return code. That is to say, OS. System () returns 256, that is, 0 × 0100, And the return code should be its high position 0 × 01, that is, 1.