Re: subprocess returncode is masked

2009-12-30 Thread Nobody
On Mon, 28 Dec 2009 17:12:23 +0100, 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 ?

That's how Unix works.

The exit status of a process as reported by wait() (etc) is a 16-bit
value (the first Unix systems had a 16-bit int). The top 8 bits (8-15)
contain the exit code passed to exit() or returned from main(),
truncated to 8 bits. The bottom 7 bits (0-6) contain the signal number if
the process was terminated by a signal. Bit 7 is set if the process dumped
core.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: subprocess returncode is masked

2009-12-30 Thread Yinon Ehrlich
On Dec 30, 7:59 pm, Nobody nob...@nowhere.com wrote:
 On Mon, 28 Dec 2009 17:12:23 +0100, 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 ?

 That's how Unix works.

 The exit status of a process as reported by wait() (etc) is a 16-bit
 value (the first Unix systems had a 16-bit int). The top 8 bits (8-15)
 contain the exit code passed to exit() or returned from main(),
 truncated to 8 bits. The bottom 7 bits (0-6) contain the signal number if
 the process was terminated by a signal. Bit 7 is set if the process dumped
 core.

See also: http://docs.python.org/library/os.html#os.wait
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: subprocess returncode is masked

2009-12-29 Thread Emmanuel

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 ?!

--
http://mail.python.org/mailman/listinfo/python-list


Re: subprocess returncode is masked

2009-12-29 Thread Steve Holden
Emmanuel wrote:
 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 ?!

Yes, but the parameter type is a superset of the function's domain.
That's not so unusual - consider math.sqrt(), for example. Its parameter
type is float, but what happens when you call math.float(-3.5)?

regards
 Steve
-- 
Steve Holden   +1 571 484 6266   +1 800 494 3119
PyCon is coming! Atlanta, Feb 2010  http://us.pycon.org/
Holden Web LLC http://www.holdenweb.com/
UPCOMING EVENTS:http://holdenweb.eventbrite.com/
-- 
http://mail.python.org/mailman/listinfo/python-list


subprocess returncode is masked

2009-12-28 Thread Emmanuel
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 ?
Emmanuel
--
http://mail.python.org/mailman/listinfo/python-list


Re: subprocess returncode is masked

2009-12-28 Thread webtourist
On Dec 28, 11:12 am, Emmanuel emmanuel.gau...@pragmadev.com 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 ?
 Emmanuel

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: subprocess returncode is masked

2009-12-28 Thread MRAB

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.
--
http://mail.python.org/mailman/listinfo/python-list