Steven D'Aprano wrote:
On Thu, 12 Nov 2009 19:30:01 +0000, MRAB wrote:
I don't understand that. Exit status codes on all systems I'm familiar
with are limited to 0 through 255. What operating system are you using?
Assuming your system allows two-byte exit statuses, you should check
the documentation for echo and the shell to see why it is returning
256.
In some OSs the exit status consists of 2 fields, one being the child
process's exit status and the other being supplied by the OS.
Which OSes?
The reason is simple. What if the child process terminated abnormally?
You'd like an exit status to tell you that,
Which it does. Anything other than 0 is an error. I see that, for
example, if I interrupt "sleep 30" with ctrl-C instead of waiting for it
to exit normally, it returns with an exit status of 130.
[st...@soy ~]$ sleep 3 # no interrupt
[st...@soy ~]$ echo $?
0
[st...@soy ~]$ sleep 3 # interrupt with ctrl-C
[st...@soy ~]$ echo $?
130
I get the same result on a Linux box and a Solaris box, both running bash.
but you wouldn't want it to
be confused with the child process's own exit status, assuming that it
had terminated normally.
I don't understand what you mean here. Why are you assuming it terminated
normally if it terminated abnormally?
You want to be able to distinguish between a child process terminating
with an exit status, and failing to run a child process for some reason.
--
http://mail.python.org/mailman/listinfo/python-list