?
Solved

Handling SIGFPE signal

Posted on 2004-09-07
4
Medium Priority
?
699 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 500 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

Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

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…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses

650 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