// This stuff works ONLY on SOLARIS
// Definition of a function called SetSignal
// This is to be used instead of "signal"
// will automatically re-enable singals after handling a signal
typedef void Sigfunc(...);
Sigfunc *SetSignal(int signo, Sigfunc *func) {
struct sigaction act, oldAct;
act.sa_handler = func;
sigemptyset(&act.sa_mask);
act.sa_flags = 0;
#if SA_INTERRUPT
act.sa_flags |= SA_INTERRUPT;
#endif
#if SA_RESTART
act.sa_flags |= SA_RESTART;
#endif
#if SA_SIGINFO
act.sa_flags |= SA_SIGINFO;
#endif
if (sigaction(signo, &act, &oldAct) < 0)
return((Sigfunc *)SIG_ERR);
return((Sigfunc *)oldAct.sa_handler);
}
------------
// usage of SetSignal inside the main program.
if (SetSignal(SIGSEGV, (Sigfunc *)PageFaultHandler) == (Sigfunc *)SIG_ERR)
_error("SetSignal", fatal);
-------
// definition of PageFaultHandler
static void PageFaulthandler(int /*sig*/, struct siginfo *si, int /*c*/) {
//magic code to get the address of faulting data.
caddr_t addr = (caddr_t) si->_data._fault._addr;
blah blah
}