forked from Vhex-Kernel-Core/fxlibc
32 lines
592 B
C
32 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;
|
||
|
}
|