mirror of
https://git.planet-casio.com/Vhex-Kernel-Core/fxlibc.git
synced 2025-04-19 09:27:00 +02:00
31 lines
592 B
C
31 lines
592 B
C
#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;
|
|
}
|