shithub: npe

ref: f02dd042e341527ab750892bfc919b0883a93dd1
dir: npe/libnpe/sigaction.c

View raw version
#include <signal.h>

/* FIXME this only supports a single handler */

static sa_handler last;

static int
handler(void*, char *s)
{
	/* kill is kill */
	if(strcmp(s, "kill") != 0 && strcmp(s, "threadint") != 0)
		last(SIGSEGV);
	return 0;
}

void
sigaction(int, struct sigaction *act, struct sigaction *)
{
	if(act != nil && last == nil){
		last = act->sa_handler;
		atnotify(handler, 1);
	}else if(act == nil){
		atnotify(handler, 0);
	}
}