> 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 [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message

Reply via email to