Where is the earliest position to set the exitcode? Which exitcode does the program generate if an error occurs? For example a seg fault.
Mailing lists / fpc-pascal / 2008-12
exitcode
6 messages · 2 people ·
- JJonas Maebe 3
- RRainer Stratmann 3
Reply by email Subscribe to this list Your subscription
Read-only archive. Use j and k to move between messages.
Rainer Stratmann wroteWhere is the earliest position to set the exitcode?
What do you mean with "position"?
Which exitcode does the program generate if an error occurs?
Depends on the error. It's the same as the run time error number for that fault, see http://www.freepascal.org/docs-html/user/userap4.html
For example a seg fault.
214 or 216, depending on the operating system and the kind of "segfault" (some report them as bus errors, some as segmentation faults). It seems however that it's not documented that run time error 214 can also mean bus error.
Jonas
Jonas Maebe wroteOn 28 Dec 2008, at 18:16, Rainer Stratmann wrote: > Where is the earliest position to set the exitcode? What do you mean with "position"?
Which unit first executes to set the exitcode as early as possible.
Show quoted text 11 lines
That helps me, thanks, Rainer
Show quoted text 5 lines
Rainer Stratmann wrote 6 lines
The exit code is initialised as 0. You cannot set it to something else without at the same time terminating the program (using the halt() procedure). Well, you can change it, but it will be overwritten with the actual exit code when the program really terminates (the parameter of halt, or a run time error number).
Jonas
Jonas Maebe wrote 16 lines
Here with Linux OS it works if I set the exitcode var. Nothing overwritten by the program.
program1 calls program2 and program2 says with the exitcode if program1 restarts program2 or finish all.
That works without calling halt(), if no error occurs.
Rainer
Rainer Stratmann wrote 20 lines
Ah, yes. I forgot about the situation where you just return from the main program. Still, I've never before heard of someone doing that and it does not seem very clean to me. But I can't immediately think how it would break either.
Jonas
