ftp.nice.ch/pub/next/developer/languages/lisp/AKCL.1.599.s.tar.gz#/akcl-1-599/c/unixint.c

This is unixint.c in view mode; [Download] [Up]

/*
(c) Copyright Taiichi Yuasa and Masami Hagiya, 1984.  All rights reserved.
Copying of this file is authorized to users who have executed the true and
proper "License Agreement for Kyoto Common LISP" with SIGLISP.
*/

/*
	unixint.c
*/

#include "include.h"
#include <signal.h>

object SVinterrupt_enable;

sigalrm()
{
	if (interrupt_flag) {
		interrupt_flag = FALSE;
		terminal_interrupt(TRUE);
	}
}

sigint()
{
	if (!interrupt_enable || interrupt_flag) {

		if (!interrupt_enable)
			{fprintf(stdout, "\n;;Interrupt delayed.\n");
			 fflush(stdout);
			 interrupt_flag=TRUE;}

		akcl_signal(SIGINT, sigint);
		return;
	}
	if (symbol_value(SVinterrupt_enable) == Cnil) {
		SVinterrupt_enable->s.s_dbind = Ct;
		akcl_signal(SIGINT, sigint);
		return;
	}
	interrupt_flag = TRUE;
	akcl_signal(SIGALRM, sigalrm);
	alarm(1);
	akcl_signal(SIGINT, sigint);
}

sigfpe()
{
	akcl_signal(SIGFPE, sigfpe);
	FEerror("Floating-point exception.", 0);
}

#ifdef BSD
signal_catcher(sig, code, scp)
{
	char str[64];

	if (!interrupt_enable) {
		sprintf(str, "signal %d caught (during GBC)", sig);
		error(str);
	} else {
		vs_push(make_fixnum(sig));
		FEerror("Signal ~D caught.~%\
The internal memory may be broken.~%\
You should check the signal and exit from Lisp.", 1, vs_head);
	}
}

siLcatch_bad_signals()
{
	check_arg(0);

	akcl_signal(SIGILL, signal_catcher);
	akcl_signal(SIGIOT, signal_catcher);
	akcl_signal(SIGEMT, signal_catcher);
	akcl_signal(SIGBUS, signal_catcher);
	akcl_signal(SIGSEGV, signal_catcher);
	akcl_signal(SIGSYS, signal_catcher);
	vs_push(Ct);
}

siLuncatch_bad_signals()
{
	check_arg(0);

	akcl_signal(SIGILL, SIG_DFL);
	akcl_signal(SIGIOT, SIG_DFL);
	akcl_signal(SIGEMT, SIG_DFL);
	akcl_signal(SIGBUS, SIG_DFL);
	akcl_signal(SIGSEGV, SIG_DFL);
	akcl_signal(SIGSYS, SIG_DFL);
	vs_push(Ct);
}
#endif

init_interrupt()
{
	akcl_signal(SIGFPE, sigfpe);
	akcl_signal(SIGINT, sigint);
}

init_interrupt1()
{
	SVinterrupt_enable
	= make_si_special("*INTERRUPT-ENABLE*", Ct);
#ifdef BSD
	make_si_function("CATCH-BAD-SIGNALS", siLcatch_bad_signals);
	make_si_function("UNCATCH-BAD-SIGNALS", siLuncatch_bad_signals);
#endif
}

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.