Python equivalent of shell's '$?'

Kragen Sitaker kragen at pobox.com
Sun Jun 2 21:33:22 EDT 2002


Dave Swegen <dswegen at software.plasmon.com> writes:
> > > (I've learnt that catching
> > > errors from sub shells is highly unreliable, and ended up having not
> > > checking for errors, as I would sometimes get spurious results back).
> 
> I can't quite remember exactly what the problem was (I seem to recall
> that the errno returned was not what the called program returned). This
> was using both open and backticks. It was yet another nail in the coffin
> that is my opinion of perl ;)

FWIW wait(2) returns a 16-bit quantity with 8 bits of exit code and 8
bits of status information (normally 0 or a signal number).  $? and
the various Python and Perl methods of getting exit status return what
wait(2) returns.  Shift it right by eight bits to get what the program
passed to _exit(2).




More information about the Python-list mailing list