Solved

Handling SIGFPE signal

Posted on 2004-09-07
4
649 Views
Last Modified: 2008-02-01
Hi,

I have a signal handler routine for SIGFPE as follows:

void myOverflowHandler(int number1) {

  printf("Error occurred: \n");
  signal(SIGFPE,myOverflowHandler);

}

The calling function in main is:

printf("%d", 10/0);
printf("Came out of loop\n");

In the routine, I do not want to terminate the process, but return control back to the error causing statement and continue to the next line. But this seems to go on in an endless loop, printing the first statement (never coming to "Came out of loop"). Can anybody let me know what is the problem?

Regards,
nganesh.
0
Comment
Question by:nganesh
  • 2
4 Comments
 
LVL 45

Expert Comment

by:sunnycoder
Comment Utility
Hi nganesh,



Sunnycoder
0
 
LVL 45

Accepted Solution

by:
sunnycoder earned 125 total points
Comment Utility
nganesh,

Sorry for the previous post
> In the routine, I do not want to terminate the process, but return control back to the error
> causing statement and continue to the next line
Look into sigsetjmp() and siglongjmp()

Sunnycoder
0
 
LVL 51

Expert Comment

by:ahoffmann
Comment Utility
if you want to exit after the very first SIGPIPE then remove
  signal(SIGFPE,myOverflowHandler); in your myOverflowHandler()
0
 
LVL 1

Author Comment

by:nganesh
Comment Utility
Thanks a lot for the answer, Sunnycoder. sigsetjmp() and siglongjmp() solved my problem. I wanted to return control back to the program after executing the handler.

Regards,
nganesh.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Have you ever been frustrated by having to click seven times in order to retrieve a small bit of information from the web, always the same seven clicks, scrolling down and down until you reach your target? When you know the benefits of the command l…
The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now