HP Pascal/iX Programmer's Guide (31502-90023)
B- 16
Old_Action := signal (SIGQUIT, Baddress (InterruptHandler));
IF Old_Action = SIG_IGN THEN
Old_Action := signal (SIGQUIT, SIG_IGN)
ELSE IF Old_Action = BADSIG THEN
{An invalid SignalNum or ProcAddress was passed};
END.
When either of the signals SIGINT or SIGQUIT is raised (by entering
CONTROL C on the keyboard, for example), the procedure InterruptHandler
is called.
NOTE In the preceding example, if InterruptHandler is to return to the
main program, its first action must be to rearm the signal
mechanism (in the manner described above) for the signal that was
trapped. This is necessary because every time a signal is trapped,
the HP-UX operating system resets its action information (the
stored value of ProcAddress) to SIG_DFL (the default action). The
program cannot resume normal execution and trap interrupts again
unless it rearms the signal handler.
Run-Time Error Handling
If HP-UX detects a run-time error, it aborts the program unless the
program defines error recovery code. Error recovery code can catch
run-time errors that originate from:
* In-line compiled code (for example: range violation errors, nil
pointer errors, math overflow errors).
* Run-time support routines (for example:
string, set, math
).
* Pascal file system (I/O errors).
* HP-UX file system support (system errors).
* Hardware (signals), except the
kill
signal.
When compiling a program, the compiler generates code that will call the
predefined procedure
escape
if HP-UX detects a run-time error in the
compiled program. The procedure
escape
transfers control to the
program's error recovery code (if the program has no error recovery code,
the program aborts). For a complete explanation of error recovery code,
see Chapter 11 .
Run-time errors in in-line compiled code are unique in that they can be
suppressed--that is, you can tell the compiler not to generate code to
catch them (see the compiler option RANGE in the
HP Pascal/HP-UX
Reference Manual
). Run-time errors from other sources cannot be
suppressed.
Most run-time errors that arise from interaction between in-line compiled
code and run-time support routines are I/O errors. A few are system
errors.