a C standard library for fx Casio calculators
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
fxlibc/src/libc/signal/raise.c

31 lines
592 B

#include <signal.h>
#include <bits/signum.h>
#include <stdlib.h>
#include "signal_p.h"
int raise(int sig)
{
if(sig < 0 || sig >= _NSIG)
return 1;
/* TODO: libc/signal: support signal masks? */
__sighandler_t handler = signal(sig, SIG_DFL);
if(handler == SIG_DFL) {
/* Signals that terminate */
if(sig == SIGINT || sig == SIGTERM) {
exit(128 + sig);
}
/* Signals that abort */
if(sig == SIGILL || sig == SIGABRT || sig == SIGFPE ||
sig == SIGSEGV) {
_Exit(128 + sig);
}
}
else if(handler != SIG_IGN) {
(*handler)(sig);
}
signal(sig, handler);
return 0;
}