signal handling of sorts

cvs 0.62
Slava Pestov 2004-08-17 01:05:38 +00:00
parent 70ea45ab84
commit 05a44aa547
6 changed files with 22 additions and 0 deletions

View File

@ -64,6 +64,7 @@ USE: vectors
"Overflow"
"Incomparable types: "
"Float format: "
"Signal "
] ?nth ;
: ?kernel-error ( cons -- error# param )

View File

@ -7,6 +7,7 @@
#define ERROR_OVERFLOW (6<<3)
#define ERROR_INCOMPARABLE (7<<3)
#define ERROR_FLOAT_FORMAT (8<<3)
#define ERROR_SIGNAL (9<<3)
void fatal_error(char* msg, CELL tagged);
void critical_error(char* msg, CELL tagged);

View File

@ -15,6 +15,7 @@ int main(int argc, char** argv)
init_stacks();
init_iomux();
init_io();
init_signals();
run();

View File

@ -6,6 +6,7 @@
#include <limits.h>
#include <math.h>
#include <setjmp.h>
#include <signal.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>

View File

@ -1,5 +1,21 @@
#include "factor.h"
void signal_handler(int signal, siginfo_t* siginfo, void* uap)
{
general_error(ERROR_SIGNAL,tag_fixnum(signal));
}
void init_signals(void)
{
struct sigaction custom_sigaction;
custom_sigaction.sa_sigaction = signal_handler;
custom_sigaction.sa_flags = SA_SIGINFO;
sigaction(SIGABRT,&custom_sigaction,NULL);
sigaction(SIGFPE,&custom_sigaction,NULL);
sigaction(SIGBUS,&custom_sigaction,NULL);
sigaction(SIGSEGV,&custom_sigaction,NULL);
}
void clear_environment(void)
{
int i;

View File

@ -33,6 +33,8 @@ typedef struct {
ENV env;
void init_signals(void);
void clear_environment(void);
INLINE CELL dpop(void)