signal handling made more generic
git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@290 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
70
C/sysbits.c
70
C/sysbits.c
@@ -823,7 +823,6 @@ STATIC_PROTO (void InitSignals, (void));
|
||||
|
||||
STATIC_PROTO (void HandleSIGSEGV, (int, siginfo_t *, ucontext_t *));
|
||||
STATIC_PROTO (void HandleMatherr, (int, siginfo_t *, ucontext_t *));
|
||||
STATIC_PROTO (void HandleSIGUSER, (int, siginfo_t *, ucontext_t *));
|
||||
STATIC_PROTO (void my_signal_info, (int, void (*)(int, siginfo_t *, ucontext_t *)));
|
||||
STATIC_PROTO (void my_signal, (int, void (*)(int, siginfo_t *, ucontext_t *)));
|
||||
|
||||
@@ -906,7 +905,6 @@ my_signal(int sig, void (*handler)(int, siginfo_t *, ucontext_t *))
|
||||
|
||||
STATIC_PROTO (RETSIGTYPE HandleMatherr, (int));
|
||||
STATIC_PROTO (RETSIGTYPE HandleSIGSEGV, (int));
|
||||
STATIC_PROTO (RETSIGTYPE HandleSIGUSER, (int));
|
||||
STATIC_PROTO (void my_signal_info, (int, void (*)(int)));
|
||||
STATIC_PROTO (void my_signal, (int, void (*)(int)));
|
||||
|
||||
@@ -1011,7 +1009,7 @@ HandleSIGSEGV(int sig)
|
||||
SearchForTrailFault();
|
||||
}
|
||||
|
||||
#ifdef HAVE_SIGACTION
|
||||
#if HAVE_SIGACTION
|
||||
|
||||
static void
|
||||
my_signal_info(int sig, void (*handler)(int))
|
||||
@@ -1253,40 +1251,10 @@ HandleALRM(int s)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if USE_SIGACTION
|
||||
/* this routine is called if YAP received one of the signals that
|
||||
can be handled by user code, currently SIGUSR1 and SIGUSR2 */
|
||||
static RETSIGTYPE
|
||||
#if (defined(__svr4__) || defined(__SVR4))
|
||||
HandleSIGUSER (int s, siginfo_t *x, ucontext_t *y)
|
||||
#else
|
||||
HandleSIGUSER(int s)
|
||||
#endif
|
||||
{
|
||||
/* force the system to creep */
|
||||
p_creep ();
|
||||
/* raise the '$sig_pending' flag */
|
||||
/* NOTE: shouldn't this be a queue? */
|
||||
switch (s) {
|
||||
case SIGUSR1:
|
||||
PutValue(AtomSigPending, MkAtomTerm(LookupAtom("sig_usr1")));
|
||||
break;
|
||||
case SIGUSR2:
|
||||
PutValue(AtomSigPending, MkAtomTerm(LookupAtom("sig_usr2")));
|
||||
break;
|
||||
default:
|
||||
/* should never be here, freak out and die! */
|
||||
/* YapErrorWhatever(); */
|
||||
;
|
||||
}
|
||||
}
|
||||
#endif /* USE_SIGACTION */
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* This function is called after a normal interrupt had been caught It allows
|
||||
* 6 possibilities : abort, continue, trace, debug, help, exit
|
||||
* This function is called after a normal interrupt had been caught.
|
||||
* It allows 6 possibilities: abort, continue, trace, debug, help, exit.
|
||||
*/
|
||||
|
||||
#if !defined(LIGHT) && !_MSC_VER && !defined(__MINGW32__) && !defined(LIGHT)
|
||||
@@ -1311,9 +1279,30 @@ ReceiveSignal (int s)
|
||||
case SIGKILL:
|
||||
exit_yap (SIGKILL, "\n\n\n[ Quit signal received ]\n\n");
|
||||
#endif
|
||||
case SIGUSR1:
|
||||
/* force the system to creep */
|
||||
p_creep ();
|
||||
/* raise the '$sig_pending' flag */
|
||||
/* NOTE: shouldn't this be a queue? */
|
||||
PutValue(AtomSigPending, MkAtomTerm(LookupAtom("sig_usr1")));
|
||||
break;
|
||||
case SIGUSR2:
|
||||
/* force the system to creep */
|
||||
p_creep ();
|
||||
/* raise the '$sig_pending' flag */
|
||||
/* NOTE: shouldn't this be a queue? */
|
||||
PutValue(AtomSigPending, MkAtomTerm(LookupAtom("sig_usr2")));
|
||||
break;
|
||||
case SIGHUP:
|
||||
/* force the system to creep */
|
||||
p_creep ();
|
||||
/* raise the '$sig_pending' flag */
|
||||
/* NOTE: shouldn't this be a queue? */
|
||||
PutValue(AtomSigPending, MkAtomTerm(LookupAtom("sig_hup")));
|
||||
break;
|
||||
default:
|
||||
YP_fprintf(YP_stderr, "\n[ Unexpected signal ]\n");
|
||||
exit (FALSE);
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1340,7 +1329,10 @@ InitSignals (void)
|
||||
#if !defined(LIGHT) && !_MSC_VER && !defined(__MINGW32__) && !defined(LIGHT)
|
||||
my_signal (SIGQUIT, ReceiveSignal);
|
||||
my_signal (SIGKILL, ReceiveSignal);
|
||||
my_signal(SIGALRM, HandleALRM);
|
||||
my_signal (SIGUSR1, ReceiveSignal);
|
||||
my_signal (SIGUSR2, ReceiveSignal);
|
||||
my_signal (SIGHUP, ReceiveSignal);
|
||||
my_signal (SIGALRM, HandleALRM);
|
||||
#endif
|
||||
#if _MSC_VER || defined(__MINGW32__)
|
||||
signal (SIGINT, SIG_IGN);
|
||||
@@ -1348,10 +1340,6 @@ InitSignals (void)
|
||||
#else
|
||||
my_signal (SIGINT, HandleSIGINT);
|
||||
#endif
|
||||
#if USE_SIGACTION
|
||||
my_signal (SIGUSR1, HandleSIGUSER);
|
||||
my_signal (SIGUSR2, HandleSIGUSER);
|
||||
#endif
|
||||
#ifndef MPW
|
||||
my_signal (SIGFPE, HandleMatherr);
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user