[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[LCP]SIGFPE



Hello,

I'm a novice in signal field. I was trying to out a simple program 
(which I've pasted below). When the binary was executed, signal 
handler for SIGFPE was executed continuously even though I've 
written a signal handler for it.

My query is, why kernel continuously gives this signal to my 
program Or Am I missing something in my code??

If I reset signal handler for SIGFPE to defualt one in the signal 
handler function, then my program gets terminated.

Regards,
Madhav.

======================================================
#include <signal.h>
#include <stdio.h>
#include <unistd.h>

void sighand(int sig)
{
  printf("\nSig Recd %d", sig);
  /*
  ** Should signal handler be reset here for SIGFPE to default 
here ????
  */
}

int main()
{

struct sigaction act;
int j=10,k;

act.sa_handler = sighand;
sigemptyset(&act.sa_mask);
act.sa_flags = 0;

sigaddset(&act.sa_mask, SIGFPE);

(void) sigaction(SIGFPE, &act, 0);

k=j/0;

printf("\ndone!!\n");

return 0;

}
======================================================
_________________________________________________________
There is always a better job for you at Monsterindia.com.
Go now http://monsterindia.rediff.com/jobs