Wrong exist status for os.system, os.poepen, etc.

Paul Boddie paul at boddie.org.uk
Tue Mar 6 10:51:22 EST 2007


On 6 Mar, 16:39, "Paolo Pantaleo" <paolopanta... at gmail.com> wrote:
>
> The os.system() (but all the other funciont with similar behavior) reports
> wrong exit status. I can reproduce the bug in the following way

I think you should look at some previous threads related to this
(obtained by searching Google Groups for "os.system exit status
code"):

"grabbing return codes from os.system() call"
http://groups.google.com/group/comp.lang.python/browse_frm/thread/efeab8a50ff16975/

"please help me understand os.system() result"
http://groups.google.com/group/comp.lang.python/browse_frm/thread/4a9ab6d5a609e9ca/

"os.system() << 8 ?"
http://groups.google.com/group/comp.lang.python/browse_frm/thread/f12ccab6389f482c/

In short, the returned code is actually a combination of two values,
and you need to extract the expected status code by shifting the
result 8 bits to the right. It may actually be more complicated than
that, but the man page for system ("man 3 system") explains this in
more detail.

Paul




More information about the Python-list mailing list