From 502e15be8ec14819ab276f15adb33e62a92ea63b Mon Sep 17 00:00:00 2001 From: stasinos Date: Tue, 15 Jan 2002 15:44:57 +0000 Subject: [PATCH] change the sig_pending flag int a stack git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@294 b08c6af1-5177-4d33-ba66-4b1c6b8b522a --- C/sysbits.c | 31 +++++++++++++++++++++---------- pl/debug.yap | 23 ++++++++++++----------- 2 files changed, 33 insertions(+), 21 deletions(-) diff --git a/C/sysbits.c b/C/sysbits.c index f4a8817fe..ab1732cbb 100644 --- a/C/sysbits.c +++ b/C/sysbits.c @@ -1279,29 +1279,40 @@ ReceiveSignal (int s) case SIGKILL: exit_yap (SIGKILL, "\n\n\n[ Quit signal received ]\n\n"); #endif -#if HAVE_SIGACTION +#if defined(SIGUSR1) 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"))); + /* add to the set of signals pending */ + { + Term t; + t = GetValue(AtomSigPending); + t = MkPairTerm(MkAtomTerm(LookupAtom("sig_usr1")), t); + PutValue(AtomSigPending, t); + } break; +#endif /* defined(SIGUSR1) */ +#if defined(SIGUSR2) 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"))); + /* add to the set of signals pending */ + { + Term t; + t = GetValue(AtomSigPending); + t = MkPairTerm(MkAtomTerm(LookupAtom("sig_usr2")), t); + PutValue(AtomSigPending, t); + } break; +#endif /* defined(SIGUSR2) */ +#if defined(SIGHUP) 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; -#endif +#endif /* defined(SIGHUP) */ default: YP_fprintf(YP_stderr, "\n[ Unexpected signal ]\n"); exit (EXIT_FAILURE); @@ -1333,7 +1344,7 @@ InitSignals (void) my_signal (SIGKILL, ReceiveSignal); my_signal (SIGUSR1, ReceiveSignal); my_signal (SIGUSR2, ReceiveSignal); - my_signal (SIGHUP, ReceiveSignal); + my_signal (SIGHUP, ReceiveSignal); my_signal (SIGALRM, HandleALRM); #endif #if _MSC_VER || defined(__MINGW32__) diff --git a/pl/debug.yap b/pl/debug.yap index 9673d4484..5cb4d07f4 100644 --- a/pl/debug.yap +++ b/pl/debug.yap @@ -720,17 +720,11 @@ debugging :- ), '$execute'(M:Goal). '$creep'(G) :- - format( 'creeping...~n', [] ), - '$get_value'('$sig_pending', Signal), - format( 'Signal == ~q~n', [Signal] ), - Signal \== [], !, - '$set_value'('$sig_pending', []), - ( '$recorded'('$sig_handler', action(Signal,A),_) -> - '$execute'(A), - G=[M|Goal] - ; - true - ), + '$get_value'('$sig_pending', Signals), + Signals \== [], !, + '$set_value'('$sig_pending', [] ), + '$handle_signals'(Signals), + G=[M|Goal], '$execute'(M:Goal). '$creep'(_) :- '$get_value'('$throw', true), !, @@ -750,6 +744,13 @@ debugging :- '$msg'(P,G,Mod,L,SL). '$trace'(_,_,_,_). +'$handle_signals'([]). +'$handle_signals'([S|Rest]) :- + '$recorded'('$sig_handler', action(S,A),_), + '$execute'(A), + '$handle_signals'(Rest). +'$handle_signals'([_|Rest]). + '$msg'(P,G,Module,L,SL):- flush_output(user_output), flush_output(user_error),