Bitshifted exit status from Popen3
Sean 'Shaleh' Perry
shalehperry at attbi.com
Fri Jul 12 21:26:44 EDT 2002
On 13-Jul-2002 Mike Wakerly wrote:
> Greetings all,
>
> I am encountering a peculiarity when trying to
> retreive the exit status of a command executed with
> popen2.Popen3.
>
> The effect is that the returned object in res =
> popen2.Popen3(...) has a res.status value 256x greater
> than it should (eg, bitshited to the left eight places?!)
>
according to the popen() man page it returns the same value as wait4. From
that man page:
WEXITSTATUS(status)
evaluates to the least significant eight bits of
the return code of the child which terminated,
which may have been set as the argument to a call
to exit() or as the argument for a return statement
in the main program. This macro can only be evaluĀ
ated if WIFEXITED returned non-zero.
in other words, this is expected behavior. The shell knows how to interpret it
for you which is why you have never seen it before.
More information about the Python-list
mailing list