exit status really is only 8 bits

Stephen Weeks MLton@sourcelight.com
Mon, 9 Jul 2001 10:18:47 -0700


> The fact that OS.Process.exit takes an integer argument is completely insane.
> I know that the basis documentation explicitly says that on Posix systems  it
> does,  but this is looney.  Even worse, SML/NJ (and sadly MLton) don't detect
> the `overflow'.  The exit status of a process holds some bits indicating what
> signal the process died as a result of receiving, and, if it did not die from
> a signal but used the exit system call, 8 bits  of  status  passed  to  exit.
> Note, ONLY 8 bits.
> 
> I  would  say that because of this the right thing to use is Word8.word, or a
> more abstract type, not int.  If int is used, then  an  exception  should  be
> raised if it is not in [0, 256).
> 
> I  know  that departing from the int that the basis spec kind-of requires may
> be painful, but could we at least raise some kind of exception  in  the  case
> that it isn't in this range?

I hadn't noticed the comment in the basis library specs that says

	On Posix-based systems, status will be be int. 

I had always thought of status as an abstract type.  That is stupid.  I agree.
I'll put in a raise Fail in the MLton code.