Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #40458

Re: Different behavior with multiprocessing

References <c25680d3-6814-4d5f-a5a2-aa4b9bb0c3a0@googlegroups.com> <eefa1330-cab9-448f-a9a1-c5f34c4600de@googlegroups.com>
Date 2013-03-05 02:44 +1100
Subject Re: Different behavior with multiprocessing
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.2844.1362411893.2939.python-list@python.org> (permalink)

Show all headers | View raw


On Tue, Mar 5, 2013 at 2:35 AM, Tomas Kotal <tomas.kotal@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

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

Different behavior with multiprocessing Tomas Kotal <tomas.kotal@gmail.com> - 2013-03-04 06:31 -0800
  Re: Different behavior with multiprocessing Chris Angelico <rosuav@gmail.com> - 2013-03-05 01:58 +1100
    Re: Different behavior with multiprocessing Tomas Kotal <tomas.kotal@gmail.com> - 2013-03-04 07:12 -0800
    Re: Different behavior with multiprocessing Tomas Kotal <tomas.kotal@gmail.com> - 2013-03-04 07:12 -0800
  Re: Different behavior with multiprocessing Tomas Kotal <tomas.kotal@gmail.com> - 2013-03-04 07:35 -0800
    Re: Different behavior with multiprocessing Chris Angelico <rosuav@gmail.com> - 2013-03-05 02:44 +1100

csiph-web