Date: Thu, 20 Feb 2003 03:30:34 +0100 (CET) From: Vaclav Haisman <V.Haisman@sh.cvut.cz> To: Terry Lambert <tlambert2@mindspring.com> Cc: Vaclav Haisman <V.Haisman@sh.cvut.cz>, <freebsd-hackers@freebsd.org> Subject: Re: Raising SIGSEGV in SIGSEGV handler makes FreeBSD loop Message-ID: <20030220032757.S96729-100000@logout.sh.cvut.cz> In-Reply-To: <3E5437CB.DC14EC42@mindspring.com>
next in thread | previous in thread | raw e-mail | index | archive | help
> Because POSIX mandates that it do so?
>
> man 3 signal tells us:
>
> The handled signal is unblocked when the function returns and the process
> continues from where it left off when the signal occurred. Unlike previ-
> ous signal facilities, the handler func() remains installed after a sig-
> nal has been delivered.
>
> If you want this to not happen, you should explicitly uninstall the
> handler, or you should call abort(3) (or _exit(2), if you don't want
> to leave a core dump).
Even though this is probably about my misunderstanding of things I post here
the test I used.
Vaclav Haisman
#include <signal.h>
#include <stdlib.h>
#include <iostream>
int f (int * x);
void handler (int, siginfo_t * info, ucontext_t * uap)
{
std::cerr << "SIGSEGV has been caught" << std::endl;
struct sigaction mysig;
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;
abort();
}
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 majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030220032757.S96729-100000>
