Hi,
I have been playing with signals handling and I've found one thing where
FreeBSD differes from other unix systems that I have access to. This test loops
endlessly in FreeBSD but terminates in SunOS 9 and GNU/Linux. It is as test for
what happens when a program raises SIGSEGV in SIGSEGV handler. If this touches
undefined behaviour then I think the behaviour of the other two systems is
saner.
Vaclav Haisman
#include <signal.h>
#include <iostream>
int f (int * x);
void handler (int, siginfo_t * info, ucontext_t * uap)
{
std::cerr << "SIGSEGV caught, dumping core" << std::endl;
struct sigaction mysig;
mysig.sa_handler = SIG_IGN;
mysig.sa_sigaction = NULL;
mysig.sa_flags = 0;
if (sigaction(SIGSEGV, &mysig, NULL) == -1)
{
std::cerr << "Error in sigaction()" << std::endl;
return;
}
f((int*)NULL);
mysig.sa_handler = SIG_DFL;
mysig.sa_sigaction = NULL;
mysig.sa_flags = 0;
if (sigaction(SIGSEGV, &mysig, NULL) == -1)
{
std::cerr << "Error in sigaction()" << std::endl;
return;
}
}
int f (int * x)
{
int y = *x;
return y;
}
int main ()
{
struct sigaction mysig;
mysig.sa_handler = NULL;
mysig.sa_sigaction = (void (*)(int, __siginfo *, void *))handler;
sigemptyset(&mysig.sa_mask);
sigaddset(&mysig.sa_mask, SIGSEGV);
mysig.sa_flags = SA_SIGINFO;
if (sigaction(SIGSEGV, &mysig, NULL) == -1)
{
std::cerr << "Error in sigaction()" << std::endl;
return 1;
}
int * x = NULL;
int y;
y = f(x);
return y;
}
To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message