[Mono-list] help needed

Dietmar Maurer dietmar@ximian.com
23 Nov 2001 17:40:26 +0100


On Fri, 2001-11-23 at 17:31, Dietmar Maurer wrote:
> Can someone tell me why the following program ends in an endless loop?
> How can I avoid that?

One theory is that the handler returns to the same instruction how
caused the signal, so the same instruction raises the same signal again
and again?

If so, how can I modify the IP to point to a new location?

- Dietmar

> 
> - Dietmar
> 
> 
> #include <stdio.h>
> #include <signal.h>
> 
> static void
> fp_signal_handler (int sig, siginfo_t *si, struct sigcontext *ctx)
> {
> 	printf ("TEST %d %p %p\n", si->si_code, si->si_addr, ctx->eip);
> 
> 	return;
> }
> 
> int
> main ()
> {
> 	int a = 5, b = 0;
> 	struct sigaction sa, sao;
> 
> 	sa.sa_sigaction = fp_signal_handler;
> 	sigemptyset (&sa.sa_mask);
> 	sa.sa_flags = SA_SIGINFO;
> 	sigaction (SIGFPE, &sa, NULL);
> 	
> 	return a/b;
> }
>