previous next top complete contents complete index framed top this page unframed
8.1. Signals Handled by MAINSAIL
MAINSAIL establishes handlers for a number of UNIX signals, mostly
signals representing program errors that you might want to investigate
by entering the MAINSAIL debugger.
When MAINSAIL intercepts such a signal, then (unless the signal is
used for other purposes, as described
in Section 8.2),
MAINSAIL raises a program-visible exception, which you may handle in
your program, or which you may allow to go unhandled, in which case
errMsg will be called and will
issue its usual prompt, which allows you
to enter the debugger.
MAINSAIL currently establishes handlers for the following signals on all UNIX platforms, provided that the signals are not ignored when MAINSAIL first gains control (except for additional signals as described in Section 8.2):
| Temporary feature: subject to change |
| SIGBUS SIGEMT SIGILL SIGABRT SIGPIPE SIGSEGV SIGSYS SIGTRAP |
Note that the above list of signals is subject to change.
8.2. UNIX Signals MAINSAIL Depends On
On some UNIX platforms, MAINSAIL detects some conditions (e.g.,
debugger breakpoints) using instructions that can generate a
processor-specific exception, which in turn is translated to a
UNIX signal.
MAINSAIL establishes handlers for such signals, and depends on
being able to intercept the signals; MAINSAIL
will not work correctly if you establish your own handler for
the signals in question.
Therefore, as long as MAINSAIL is executing,
you should not set up a UNIX signal handler for
signals MAINSAIL depends on.
Those signals include:
| Temporary feature: subject to change |
| LINIA64, LINPN: | SIGFPE, SIGSEGV |
| RAIX: | SIGFPE, SIGTRAP |
| All other platforms: | SIGFPE |
If you invoke foreign code that sets up handlers for these signals, you should be sure to save the MAINSAIL signal handler and restore it before returning control to MAINSAIL.
Note that the above list of signals is subject to change.
Most UNIX platforms provide more than one routine that establishes
a signal handler.
The different routines that are available are not necessarily
compatible with one another.
If you link C code that handles UNIX signals with a MAINSAIL bootstrap,
or if you make your own FLI calls from MAINSAIL to establish signal
handlers, then you need to know which UNIX signal routine to call so
that it will not conflict with MAINSAIL's signal handling.
The UNIX signal function is considered these days to have
ill-conceived
semantics, and has been superseded on some platforms by either
sigaction (on System V UNIX flavors) or sigvec (on BSD UNIX
flavors).
For backwards compatibility,
signal is implemented on these platforms in terms of either
sigaction or sigvec.
Consult the UNIX documentation for your system for a description of
each of these routines.
For a discussion of the problems with
signal, see, e.g., Chapter 10 of
Advanced Programming in the UNIX
Environment by W. Richard Stevens (Reading, Massachusetts:
Addison-Wesley Publishing Company, 1992).
The routine that MAINSAIL calls to set up a signal handler on each
UNIX platform is:
You should call the same routine when establishing your own signal
handlers.
If you use sigaction or sigvec
to establish your own handler, but later
restore the original MAINSAIL handler, you should restore the handler
with all its original flags.
Both sigaction and sigvec provide
a third parameter that records all
relevant information about the signal handler being replaced.
On sigaction and sigvec systems,
you should always use this parameter to record the original state of
the MAINSAIL signal handler, and use the same record (as the second
parameter to sigaction or sigvec)
when you restore the MAINSAIL signal
handler.
MAINSAIL signal handlers will not work correctly if the appropriate
flags are not set when the handler is established.
The routine MAINSAIL uses to establish signal handlers is subject to
change; in particular, XIDAK will usually update MAINSAIL to use the
most modern signal-handling mechanism available on each platform.
If you set up signal handlers within a MAINSAIL bootstrap, you must
change your code when MAINSAIL's signal-handling conventions change
to make sure that the routine you call to establish
a signal handler is the same as MAINSAIL's.
8.3. UNIX Signals MAINPM Uses for PC Monitoring
On systems where MAINPM's PC monitoring is available, MAINPM uses
the signal SIGALRM for real PC monitoring and SIGVTALRM
or SIGPROF for virtual PC monitoring.
If you set up your own handler for these signals, MAINPM's PC monitoring
will not work.
8.4. System Calls to Use to Establish Signal Handlers
Temporary feature: subject to change
Platform Abbreviation Signal Routine HPPA signal HPPA64 signal LINIA64 sigaction LINPN sigaction PSOLRS sigaction RAIX sigvec SOLRS sigaction SUN4 sigvec
MAINSAIL System-Specific User's Guides, Chapter 8