Hello, can anyone tell me, where I can find out the meaning of exit values of a program compiled with GPC?
I know this sourcefile, where the values from 300 to 925 are listed. But what about the others?
I did find out, that 8 means a division with zero, 11 occurs, when i tty to dereference nil, and 15 is returned, if i kill the process from outside.
Is there a list of those values somewhere?
Greetings, Michael
michael paap wrote:
Hello, can anyone tell me, where I can find out the meaning of exit values of a program compiled with GPC?
I know this sourcefile, where the values from 300 to 925 are listed. But what about the others?
I did find out, that 8 means a division with zero, 11 occurs, when i tty to dereference nil, and 15 is returned, if i kill the process from outside.
I think you're confusing two things:
The error codes (listed in rts/error.pas) are used within a GPC program (e.g. in IOResult and ExitCode). Don't rely too much of them since they might change. If you really need one use the symbolic constants listed at the top of that file (if yours is missing, we can add it on request).
However, what you seem to mean is the exit value returned to the calling process. That's generally 0 if the program exits normally or with `Halt' without parameters, and the value given when using `Halt' with a parameter.
If the program exits with a runtime error, it's RuntimeErrorExitValue (currently 42). That's independent of the error number because most systems only allow for 128 or 256 exit values, and GPC has already 216 predefined error codes with more to appear likely in the future, and users can use their own codes.
Now, if a program is killed by a signal, then the signal code is returned. That's apparently what you found out. Signal codes are system dependent (e.g., under Linux, see `man 7 signal'. In GPC programs, you get the signal values (on the current system) in the variables SigHup etc., and you can get a textual description using StrSignal.
If you have the exit value from a process you ran with `Execute' (or similar), you can use functions like StatusExited/StatusSignaled to find out if the program terminated normally or was killed by a signal, and if so StatusExitCode/StatusTermSignal to get the exit code or signal number. (Some system encode them in certain ways in the integer returned by execute etc., so examining this value directly does not lead to meaningful results.)
Frank