Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2008-12

exitcode

6 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Rainer Stratmann

Where is the earliest position to set the exitcode? Which exitcode does the program generate if an error occurs? For example a seg fault.

Jonas Maebe
to Rainer Stratmann
Rainer Stratmann wrote
Where 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

Rainer Stratmann
to Jonas Maebe
Jonas Maebe wrote
On 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
> 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.

That helps me, thanks, Rainer

Show quoted text 5 lines
Jonas _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Jonas Maebe
to Rainer Stratmann
Rainer Stratmann wrote 6 lines
Am Sonntag, 28. Dezember 2008 18:59 schrieb Jonas Maebe: > On 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.

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

Rainer Stratmann
to Jonas Maebe
Jonas Maebe wrote 16 lines
On 28 Dec 2008, at 19:31, Rainer Stratmann wrote: > Am Sonntag, 28. Dezember 2008 18:59 schrieb Jonas Maebe: >> On 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. 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

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

Jonas Maebe
to Rainer Stratmann
Rainer Stratmann wrote 20 lines
Am Sonntag, 28. Dezember 2008 19:41 schrieb Jonas Maebe: > > 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 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.

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