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
This commit is contained in:
stasinos 2002-01-15 15:44:57 +00:00
parent 4414acbdf9
commit 502e15be8e
2 changed files with 33 additions and 21 deletions

View File

@ -1279,29 +1279,40 @@ ReceiveSignal (int s)
case SIGKILL: case SIGKILL:
exit_yap (SIGKILL, "\n\n\n[ Quit signal received ]\n\n"); exit_yap (SIGKILL, "\n\n\n[ Quit signal received ]\n\n");
#endif #endif
#if HAVE_SIGACTION #if defined(SIGUSR1)
case SIGUSR1: case SIGUSR1:
/* force the system to creep */ /* force the system to creep */
p_creep (); p_creep ();
/* raise the '$sig_pending' flag */ /* add to the set of signals pending */
/* NOTE: shouldn't this be a queue? */ {
PutValue(AtomSigPending, MkAtomTerm(LookupAtom("sig_usr1"))); Term t;
t = GetValue(AtomSigPending);
t = MkPairTerm(MkAtomTerm(LookupAtom("sig_usr1")), t);
PutValue(AtomSigPending, t);
}
break; break;
#endif /* defined(SIGUSR1) */
#if defined(SIGUSR2)
case SIGUSR2: case SIGUSR2:
/* force the system to creep */ /* force the system to creep */
p_creep (); p_creep ();
/* raise the '$sig_pending' flag */ /* add to the set of signals pending */
/* NOTE: shouldn't this be a queue? */ {
PutValue(AtomSigPending, MkAtomTerm(LookupAtom("sig_usr2"))); Term t;
t = GetValue(AtomSigPending);
t = MkPairTerm(MkAtomTerm(LookupAtom("sig_usr2")), t);
PutValue(AtomSigPending, t);
}
break; break;
#endif /* defined(SIGUSR2) */
#if defined(SIGHUP)
case SIGHUP: case SIGHUP:
/* force the system to creep */ /* force the system to creep */
p_creep (); p_creep ();
/* raise the '$sig_pending' flag */ /* raise the '$sig_pending' flag */
/* NOTE: shouldn't this be a queue? */
PutValue(AtomSigPending, MkAtomTerm(LookupAtom("sig_hup"))); PutValue(AtomSigPending, MkAtomTerm(LookupAtom("sig_hup")));
break; break;
#endif #endif /* defined(SIGHUP) */
default: default:
YP_fprintf(YP_stderr, "\n[ Unexpected signal ]\n"); YP_fprintf(YP_stderr, "\n[ Unexpected signal ]\n");
exit (EXIT_FAILURE); exit (EXIT_FAILURE);
@ -1333,7 +1344,7 @@ InitSignals (void)
my_signal (SIGKILL, ReceiveSignal); my_signal (SIGKILL, ReceiveSignal);
my_signal (SIGUSR1, ReceiveSignal); my_signal (SIGUSR1, ReceiveSignal);
my_signal (SIGUSR2, ReceiveSignal); my_signal (SIGUSR2, ReceiveSignal);
my_signal (SIGHUP, ReceiveSignal); my_signal (SIGHUP, ReceiveSignal);
my_signal (SIGALRM, HandleALRM); my_signal (SIGALRM, HandleALRM);
#endif #endif
#if _MSC_VER || defined(__MINGW32__) #if _MSC_VER || defined(__MINGW32__)

View File

@ -720,17 +720,11 @@ debugging :-
), ),
'$execute'(M:Goal). '$execute'(M:Goal).
'$creep'(G) :- '$creep'(G) :-
format( 'creeping...~n', [] ), '$get_value'('$sig_pending', Signals),
'$get_value'('$sig_pending', Signal), Signals \== [], !,
format( 'Signal == ~q~n', [Signal] ), '$set_value'('$sig_pending', [] ),
Signal \== [], !, '$handle_signals'(Signals),
'$set_value'('$sig_pending', []), G=[M|Goal],
( '$recorded'('$sig_handler', action(Signal,A),_) ->
'$execute'(A),
G=[M|Goal]
;
true
),
'$execute'(M:Goal). '$execute'(M:Goal).
'$creep'(_) :- '$creep'(_) :-
'$get_value'('$throw', true), !, '$get_value'('$throw', true), !,
@ -750,6 +744,13 @@ debugging :-
'$msg'(P,G,Mod,L,SL). '$msg'(P,G,Mod,L,SL).
'$trace'(_,_,_,_). '$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):- '$msg'(P,G,Module,L,SL):-
flush_output(user_output), flush_output(user_output),
flush_output(user_error), flush_output(user_error),