Path: utzoo!utgpu!watmath!uunet!mcvax!kth!sunic!enea!sommar From: sommar@enea.se (Erland Sommarskog) Newsgroups: gnu.gcc Subject: Re: VMS exit codes Message-ID: <152@enea.se> Date: 29 Jul 89 22:49:31 GMT Organization: Enea Data AB, Sweden Lines: 56 (I happened to look into this newsgroup/mailing list, and I do not intend to stay, so please give me a copy if you follow up.) Erkki Ruohtula (eru@tnvsu1.tele.nokia.fi) writes: >Morten Kjeldgaard writes: >>$ run define >>vms defined >>%SYSTEM-F-ACCVIO, access violation, reason mask=00, virtual address=0000000C, >>PC=0000000C, PSL=00000004 > >I think this is the problem of random program exit codes. There is actually >nothing wrong with your program, except that the return value of function >"main" is random (or depends on whatever "printf" happens to leave in the >registers). First, I would hold the view that the compiler should load R0 with one, in case there no explicit exit statement. Now, I don't know C, and even less this specific compiler, but if the above is true, this is a flaw in GCC. However, I doubt that is the problem. As Erkki says, when an image terminates in VMS, DCL checks its exit status and displays the messages associated with it if the status is even. (And bit 28 is zero.) Many of the messages are parameterized to give room for file names and similar. Of course there is no chance for DCL to fill in these, so they are left with the original FAO (see below) directives. And ACCVIO is such a message. If it was the result of a random exit code, the message would have looked like: %SYSTEM-F-ACCVIO, access violation, reason mask=!XB, virtual address=!XL, PC=!XL, PSL=!XL These !XB and !XL are placeholders for FAO arguments, similar to those %s and whatever you have in C. (FAO = Formatted ASCII output, a standard system service in VMS.) >Codes below 7 are >unassigned, that is why a C program that returns 0 in the unix-style gets the >mysterious "%NONAME-W-NOMSG, Message number 00000000" upon exit. >Try typing "exit 0", "exit 6", "exit 10" etc to VMS to see the messages. Hm, not really. There is just a little special fix for it. Otherwise the message for 0 would be %SYSTEM-W-NORMAL, normal successful completion The W tells you that something is wrong, W indicates the message has the level warning. Since exitting with zero maybe a common case, for instance due to an uninitated status variable, DEC has chosen to make message 0 a special case, and display the even variants of it as %NONAME--NOMSG. Displaying the message above would be a good ground for confusion. It could also be added that it more sophisticated than odd for OK and even for failure. In fact there are five levels of the status codes: success, informational, warning, error and fatal error. Which level it is, is indicated by the three LSBs in the code. Then as a simplification, the two first ones are odd, and the three latter are even. -- Erland Sommarskog - ENEA Data, Stockholm - sommar@enea.se "Hey poor, you don't have to be Jesus!" - Front 242