Mac Intel

Joel Reymont joelr1@REDACTED
Sat Aug 12 13:16:07 CEST 2006


Something trivial like this does raise SIGFPE:

#include <signal.h>
#include <stdlib.h>

static void handler(int sig)
{
   _Exit(sig);
}

int main(int argc, char *argv[]) {
         signal(SIGFPE, handler);
         return argc / (argc - 1);
}

This program does _not_ raise SIGFPE at all!

#include <signal.h>
#include <stdlib.h>
#include <string.h>
#include <ucontext.h>
#include <stdio.h>

static void fpe_sig_action(int sig, siginfo_t *si, void *puc)
{
	printf("We are here!\n");
	_Exit(sig);
}

double a = 3.23e133;
double b = 3.57e257;
double res;

int main(int argc, char *argv[]) {
	struct sigaction act;
	memset(&act, 0, sizeof act);
	act.sa_sigaction = fpe_sig_action;
	act.sa_flags = SA_SIGINFO;
	sigaction(SIGFPE, &act, NULL);
   	return a * b;
}






More information about the erlang-questions mailing list