Solved

Handling SIGFPE signal

Posted on 2004-09-07
4
672 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
ID: 11996007
Hi nganesh,



Sunnycoder
0
 
LVL 45

Accepted Solution

by:
sunnycoder earned 125 total points
ID: 11996030
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
ID: 12000416
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
ID: 12003357
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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

696 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