version 1.16, 2002/10/26 12:48:25
|
version 1.21, 2003/01/19 23:35:34
|
Line 1
|
Line 1
|
/* signal handling |
/* signal handling |
|
|
Copyright (C) 1995,1996,1997,1998,2000 Free Software Foundation, Inc. |
Copyright (C) 1995-2003 Free Software Foundation, Inc. |
|
|
This file is part of Gforth. |
This file is part of Gforth. |
|
|
Line 21
|
Line 21
|
*/ |
*/ |
|
|
|
|
#define _GNU_SOURCE |
#include "config.h" |
|
#include "forth.h" |
#include <stdio.h> |
#include <stdio.h> |
#include <setjmp.h> |
#include <setjmp.h> |
#include <string.h> |
#include <string.h> |
Line 31
|
Line 31
|
#include <sys/ioctl.h> |
#include <sys/ioctl.h> |
#endif |
#endif |
/* #include <asm/signal.h> */ |
/* #include <asm/signal.h> */ |
|
#include <sys/types.h> |
#include <signal.h> |
#include <signal.h> |
#include "config.h" |
|
#include "forth.h" |
|
#include "io.h" |
#include "io.h" |
|
|
|
#ifndef HAVE_STACK_T |
|
/* Darwin uses "struct sigaltstack" instead of "stack_t" */ |
|
typedef struct sigaltstack stack_t; |
|
#endif |
|
|
#define DEFAULTCOLS 80 |
#define DEFAULTCOLS 80 |
#if defined(MSDOS) || defined (_WIN32) |
#if defined(MSDOS) || defined (_WIN32) |
Line 52 UCell rows=DEFAULTROWS;
|
Line 55 UCell rows=DEFAULTROWS;
|
/* systems that don't have SA_NODEFER hopefully don't block anyway */ |
/* systems that don't have SA_NODEFER hopefully don't block anyway */ |
#endif |
#endif |
|
|
|
#ifndef SA_ONSTACK |
|
#define SA_ONSTACK 0 |
|
#endif |
|
|
#ifdef SA_SIGINFO |
#ifdef SA_SIGINFO |
void install_signal_handler(int sig, void (*handler)(int, siginfo_t *, void *)) |
void install_signal_handler(int sig, void (*handler)(int, siginfo_t *, void *)) |
/* installs three-argument signal handler for sig */ |
/* installs three-argument signal handler for sig */ |
Line 73 Sigfunc *bsd_signal(int signo, Sigfunc *
|
Line 80 Sigfunc *bsd_signal(int signo, Sigfunc *
|
|
|
act.sa_handler=func; |
act.sa_handler=func; |
sigemptyset(&act.sa_mask); |
sigemptyset(&act.sa_mask); |
act.sa_flags=SA_NODEFER|SA_ONSTACK; |
act.sa_flags=SA_NODEFER; /* SA_ONSTACK does not work for graceful_exit */ |
if (sigaction(signo,&act,&oact) < 0) |
if (sigaction(signo,&act,&oact) < 0) |
return SIG_ERR; |
return SIG_ERR; |
else |
else |
Line 362 void install_signal_handlers(void)
|
Line 369 void install_signal_handlers(void)
|
}; |
}; |
int i; |
int i; |
void (*throw_handler)() = die_on_signal ? graceful_exit : signal_throw; |
void (*throw_handler)() = die_on_signal ? graceful_exit : signal_throw; |
|
#ifdef SIGSTKSZ |
stack_t sigstack; |
stack_t sigstack; |
int sas_retval=-1; |
int sas_retval=-1; |
|
|
Line 372 void install_signal_handlers(void)
|
Line 380 void install_signal_handlers(void)
|
} |
} |
if (debug) |
if (debug) |
fprintf(stderr,"sigaltstack: %s\n",strerror(sas_retval)); |
fprintf(stderr,"sigaltstack: %s\n",strerror(sas_retval)); |
|
#endif |
|
|
#define DIM(X) (sizeof (X) / sizeof *(X)) |
#define DIM(X) (sizeof (X) / sizeof *(X)) |
/* |
/* |