Program return value ?

Hallvard B Furuseth (nospam nospam) h.b.furuseth at
Fri Jan 9 17:08:15 CET 2004

George Marshall wrote:

> Hi all, I'm trying to get the exit code of a program
> I want to exec in a python script in a portable manner.
> (...)
> The only problem is that it doesn't return negative values.

On a Unix system, the exit status from a program is one byte, which on
8-bit systems can have values from 0 to 255.  So if the program does
exit(-1), the exit status is (unsigned char)-1 == 255.

I don't know how this works on other operating system, but in any case I
imagine your problem is with the possible range of the exit status, not
with python.  Maybe your program should write a value to stdout (or some
other file) instead, so python could read the number.


More information about the Python-list mailing list