
	  
	 Interrupt Utility
	 
	  
 
//*****************************************************************************
//***  Interrupt facility.
//***
//***    This uses the signal facility to control set a flag when the user
//***    hits ^c.  The evalution method simply checks this flag and turns
//***    it into a lisp error when it has been set.
//***    
//*****************************************************************************
#include <signal.h>
#ifndef _interrupt_h_
#define _interrupt_h_
// Interrupt facilty.  Actually needed by apply.
extern bool signalled;          // A signal has been received.
// Vector which just sets the flag.
extern void whap(int sig);
// This initializes the facility by asking the system to call whap() when
// the user hits ^c (SIGINT), or uses the kill command with no signal
// specified (SIGTERM is the default for the Unix kill command).
inline void initsig(void)
{
        signal(SIGINT, whap);
        signal(SIGTERM, whap);
}
// Test the flag, clearing it after the test.  This allows code to use
// if(zapped()) return Error() without having to worry about clearing the
// flag itself so it's not seen again.
inline bool zapped(void)
{
        bool oldsig = signalled;
        signalled = false;
        return oldsig;
}
#endif
#include "interrupt.h"
// Interrupt facilty.  Actually needed by apply.
bool signalled = false;         // A signal has been received.
// Vector which just sets the flag.
void whap(int sig) 
{
        signalled = true;
}