[6712] in Athena Bugs

home help back first fref pref prev next nref lref last post

vax 7.1H: are exit codes signed or unsigned?

daemon@ATHENA.MIT.EDU (daemon@ATHENA.MIT.EDU)
Wed Dec 26 18:35:56 1990

Date: Wed, 26 Dec 90 18:35:43 -0500
From: "Jonathan I. Kamens" <jik@pit-manager.MIT.EDU>
To: bjaspan@ATHENA.MIT.EDU
Cc: bugs@ATHENA.MIT.EDU
In-Reply-To: Barr3y.Jaspan@ATHENA.MIT.EDU, bjaspan@mit.edu's message of Thu, 20 Dec 90 19:41:28 EST <9012210041.AA15755@yaz-pistachio.MIT.EDU>

   Date: Thu, 20 Dec 90 19:41:28 EST
   From: Barr3y.Jaspan@ATHENA.MIT.EDU, bjaspan@mit.edu <bjaspan@ATHENA.MIT.EDU>

   It has a bug that causes it to exit with return status 11111111b.
   Yesterday, I was on an RT when it happened, and the shell reported
   that xrn exited with status 255; today, on a vax, the shell reported
   an exit status of -1.

   I assume that one of them is *wrong*.  This could potentially break
   some programs/shell scripts that depend on return values being
   correct.

I believe that your assumption is wrong.

The only definition of exit status is that it is an eight-bit field in
the wait union.  The definition does not say whether those eight bits
represent a signed or an unsigned value, just that they represent
eight bits of data.

The numbers 255 and -1 are equivalent when interpreted as an eight-bit
value.  Therefore, the shell is free to report an exit status of
11111111 as either -1 or 255, at its discretion.

Shell scripts that rely on the signed/unsigned nature of a valud that
is not specified as being signed or unsigned are going to lose in some
situations no matter what.  A shell script that really needs to get
the "real" exit status of a process should add 256 to whatever it gets
and take the result mod 256 as the exit value.

 Jonathan Kamens
 Project Athena Quality Assurance

home help back first fref pref prev next nref lref last post