Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 15 Sep 1998 12:22:11 +0200 (CEST)
From:      Konrad Heuer <kheuer@gwdu60.gwdg.de>
To:        freebsd-hackers@FreeBSD.ORG
Subject:   Catching SIGSEGV
Message-ID:  <Pine.BSF.3.96.980915114921.5972A-100000@gwdu60.gwdg.de>

next in thread | raw e-mail | index | archive | help

May I ask my question here although it's not correlated to FreeBSD
development?

I write a program which shall run under FreeBSD and want to catch SIGSEGV
to count these events. So the program is like this: 

int nsegv = 0;
int *ptr;
int zero = 0; 

void sighdl ( int sig )
{
  ptr = &zero;
  nsegv++; 
}

int dowork ( )
{
  int buf;

  signal(SIGSEGV, sighdl);

  ptr = InvalidAddress;
  buf = *ptr;
}

Ok, the signal handler gets called, ptr will be reset to a legal address,
but nevertheless after returning from the signal handler it will be called
again immediately resulting in an infinite loop.

Where's my mistake? What can I do to prevent that loop?
Thanks for any reply.

Regards
Konrad Heuer

// Gesellschaft fuer wissenschaftliche Datenverarbeitung mbH
// Goettingen (GWDG), Am Fassberg, D-37077 Goettingen, Germany
//
// kheuer@gwdu60.gwdg.de


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?Pine.BSF.3.96.980915114921.5972A-100000>