Exit Code

Exit Code

Hi,
When a program terminates I get a message like 'Program .. has exited with code 0.' Could anyone please help me finding all the possible code values with which a program can exit.
Thanks,
Vivek

8 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

The exit code can be anything. 0 usually means success. It's entirely up to the program to specify what the exit code is - in Fortran, you'd use CALL EXIT to set this.

Steve

Steve - Intel Developer Support

You get this message when your code hits a STOP statement. If you
want a different code you can say, for example: STOP 2000, and then
the message will be '...exited with code 2000'. You can, as an alternative,
use text: STOP 'your message goes here'.

Actually, the STOP statement doesn't set the exit value.

Steve

Steve - Intel Developer Support

Thanks. But if there is no exception handling, would the error code always be negative?
Vivek

sorry, in the last message it should have been 'exit code' not error code.
Vivek

To Steve L.: Maybe we are not talking about the same thing, but from the
form of the message he is getting it sounds like what happens in
windows when it hits a stop statement. From the on-line docs:

STOP
Statement: Terminates program execution before the end of the program unit.

Syntax

STOP [stop-code]

stop-code
(Optional) A message. It can be either of the following:

A scalar character constant of type default character.
A string of up to six digits; leading zeros are ignored. (Fortran 95/90 and FORTRAN 77 limit digits to five.)
Effect on Windows Systems

If you specify stop-code, the effect differs depending on its form, as follows:

If stop-code is specified as a character constant, the STOP statement writes the specified message to the standard error device and terminates program execution. The program returns a status of zero to the operating system.

If stop-code is specified as a string of digits, the STOP statement writes the following to the standard error device and terminates program execution:
Return code stop-code
In QuickWin programs, the following is displayed in a message box:
Program terminated with Exit Code stop-code
In both cases, the program returns a status of stop-code to the operating system as an integer.

Ah, I had forgotten that STOP nnnnn would turn that into an exit status.

I have noticed that QuickWin programs tend to have their threads exit with a status of -1, and the main program zero. If the exit status is greater than zero, that's the time to wonder what else happened.

Steve

Steve - Intel Developer Support

Leave a Comment

Please sign in to add a comment. Not a member? Join today