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:
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__)

View File

@ -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),