Different behavior with multiprocessing
Chris Angelico
rosuav at gmail.com
Mon Mar 4 10:44:44 EST 2013
On Tue, Mar 5, 2013 at 2:35 AM, Tomas Kotal <tomas.kotal at gmail.com> wrote:
> Seems like I found the problem: os._exit probably takes as parametr unsigned char, so it uses as error code whatever value it gets modulo 256:
>
> os._exit(1) # process.exitcode == 1
> os._exit(255) # process.exitcode == 255
> os._exit(256) # process.exitcode == 0
> os._exit(257) # process.exitcode == 1
> os._exit(32512) # process.exitcode == 0
>
> So on Linux it's necesary to call something like this:
> os._exit( os.system(cmd) >> 8 )
>
> Because the first byte of return value on Linux is number of signal which kills the process and the second one is actual exit code.
Yep. I had a reply part-written but you beat me to it! That is indeed
what you need if you want to chain return values.
However, why are you using os._exit? Check out the note here:
http://docs.python.org/2/library/os.html#os._exit
ChrisA
More information about the Python-list
mailing list