Solved

Handling SIGFPE signal

Posted on 2004-09-07
4
680 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

The purpose of this article is to fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
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…
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

691 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