From owner-freebsd-hackers Tue Sep 15 03:22:47 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id DAA04282 for freebsd-hackers-outgoing; Tue, 15 Sep 1998 03:22:47 -0700 (PDT) (envelope-from owner-freebsd-hackers@FreeBSD.ORG) Received: from gwdu60.gwdg.de (gwdu60.gwdg.de [134.76.10.60]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id DAA04268 for ; Tue, 15 Sep 1998 03:22:36 -0700 (PDT) (envelope-from kheuer@gwdu60.gwdg.de) Received: from localhost (kheuer@localhost) by gwdu60.gwdg.de (8.9.0/8.9.0) with SMTP id MAA06006 for ; Tue, 15 Sep 1998 12:22:11 +0200 (CEST) Date: Tue, 15 Sep 1998 12:22:11 +0200 (CEST) From: Konrad Heuer To: freebsd-hackers@FreeBSD.ORG Subject: Catching SIGSEGV Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG 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