Unix History: return code octal?

The octal representation eases the interpretation of the exit code for small values, which are the most commonly used. Should this number, which is a byte, been printed in decimal, finding which signal interrupted a process would require a little bit of calculation while in octal, they can be read as they are:

  • a process exits with status 5, gdb displays 05 which makes no difference
  • a process exits because it got a SIGINT (Control+C), gdb displays 0202 which is easier to recognize as signal #2 than 130.

Moreover, the exit status might also be a bit mask and in such case, octal (at least when you are used to it which was more common a couple of decades ago than these days) is easier to convert mentally into bits than decimal or even hexadecimal, just like for example chmod still accept an octal number to represent file permissions: 0750 = 111 101 000 = rwx r-x ---.


I don't have a copy of this text and just read the short blurb available on google books but. According to the X/Open Portability guide System V Specification Commands & Utilities pg 283(according to google books)

if an application terminates abnormally its exit status is octal 0200 + status, and there is a list of common 'status' values (which are probably also given in octal).

So it is/was a poor mans error message.

Tags:

Gdb

History