[comp.sys.amiga.programmer] What's wrong with negative return values?

umrobbin@ccu.umanitoba.ca (03/22/91)

Okay, stupid question time:

If I run this program:

main(){
    printf("Goodbye cruel world\n");
    exit(-1);
    }

funny things happen.  Under amigados, the program runs once, and then the
disk spins again and gives a random AmigaDOS error.  Under the CShell,
the program executes twice!  Also, if the return value is -2 or -3, 
the AmigaDOS CLI doesn't give any error (and runs once) but cshell still
executes it twice.  And for any negative value, the cshell variable
_lasterr is always 20.

What's up?

The CLI is Amigados 1.3, and the cshell is "Shell V4.02A" by Dillon,
Drew, Borreo & Dieni.

Steve Z
.

DXB132@psuvm.psu.edu (03/23/91)

In article <91081.211415UH2@psuvm.psu.edu>, Lee Sailer <UH2@psuvm.psu.edu> says:

>for me, too.  Specifically, it prints out "Goodbye, cruel world."
>Then it says, Unable to load "cruel"

I think negative return codes are basically reserved for cases where you
want to tell the user that what he just tried to execute was not a real
executable file. Examples are libraries and devices, which usually start with
moveq #-1,d0 / rts in case the user tries to run them.

This is an (unpublished) convention...different shells could handle return
codes in totally different ways. (But let's hope not :-)

-- Dan Babcock