473,785 Members | 2,209 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Signal handler for SIGSEGV.

Hi all,
In my current project I am using signals for error handling. Since I
cannot show full code, I have just shown important piece of code which
is relevant.

void sigsegenv()
{
printf("\n\n ********** F D S Message ***********\n\n ");
printf("\n\n ********** S E G M E N T A T I O N F A U L T
inside F D S ***********\n\n ");
exit(-1);
}
int main(void)
{
............
...........
signal ( SIGSEGV ,sigsegenv);
...........
...........
}

I think this might give some idea about what is happening.
My signal handler is not catching SIGSEGV always. Some time it is
catching sometimes not. Please let me know what am I doing wrong

Dec 30 '05
13 17723
va******@rediff mail.com wrote:

# Can I invoke longjmp in signal handler?

Your program is in a fragile state when the signal handler
is called, and it might not be possible to recover and
continue. On some systems, you can run the program in a
separate process; if it fails, it can report failure and
then exit with recovery. The caller monitors the process
and captures the result or error status.

--
SM Ryan http://www.rawbw.com/~wyrmwif/
TEMPORARILY CLOSED
BE OPENED AFTER FIRST PERIOD
Dec 30 '05 #11
> Could you please tell me about restrictions on signal handlers or where
I can find more info about restrictions on signal handlers?


Please look at the list of async-signal-safe functions.
See section "2.4.3 Signal Actions" from the document " 2.4 Signal
Concepts".
http://www.opengroup.org/onlinepubs/...l#tag_02_04_03
http://en.wikipedia.org/wiki/Signal_%28computing%29

Regards,
Markus

Dec 30 '05 #12
Ma************@ web.de wrote:
Could you please tell me about restrictions on signal handlers or where
I can find more info about restrictions on signal handlers?


Please look at the list of async-signal-safe functions.
See section "2.4.3 Signal Actions" from the document " 2.4 Signal
Concepts".
http://www.opengroup.org/onlinepubs/...l#tag_02_04_03
http://en.wikipedia.org/wiki/Signal_%28computing%29


The above links are Posix, not C. I can't remember the OP saying that
this was only for Posix systems, and if it was then this would be the
wrong group.

A better place to look would be the C standard, a draft of the latest
version being freely available if you search for n1124.pdf.
--
Flash Gordon
Living in interesting times.
Although my email address says spam, it is real and I read it.
Dec 30 '05 #13
> A better place to look would be the C standard, a draft of the latest
version being freely available if you search for n1124.pdf.

http://www.open-std.org/jtc1/sc22/wg...1997/N1124.pdf

This document (ISO/IEC 9899:TC2 Committee Draft - May 6, 2005
WG14/N1124) contains the following wording.
Page 20, section "5.2.3 Signals and interrupts":
"...
Functions shall be implemented such that they may be interrupted at any
time by a signal, or may be called by a signal handler, or both, with
no alteration to earlier, but still active, invocations' control flow
(after the interruption), function return values, or objects with
automatic storage duration.
...."

Page 167, section "7.1.4 Use of library functions":
"...
The functions in the standard library are not guaranteed to be
reentrant and may modify objects with static storage duration.
....
161) Thus, a signal handler cannot, in general, call standard library
functions.
...."

There are more descriptions about signal handling in the sections 7.14
and 7.26.6. But the term "async-signal-safe function" is not used in
the specification. I suggest to look at other information sources for
better understanding of the topic "async-signal safety".
- Multithreaded Programming Guide

http://docs.sun.com/app/docs/doc/816...w#compat-ix626
http://docs.sun.com/app/docs/doc/816...view#gen-ix561

- http://serpentine.com/blog/threads-faq/signals.html

- http://en.wikipedia.org/wiki/Reentrant
http://en.wikipedia.org/wiki/SIGSEGV

Regards,
Markus

Dec 31 '05 #14

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1655
by: rh0dium | last post by:
Hi all, I don't understand the signal module. I guess I understand what it does in principle but I can't figure out how to use it to timeout an external rsh command after a 5 seconds. Does anyone know how to do this. Here is what I have so far - which is largely based on the example on the man page.. def handler(signum, frame):
3
2680
by: LeTubs | last post by:
Hi I'm not sure if this is correct ...place to post but here goes This is what i'm trying to do, I want to write a signal / alarm handler ( I don't know which hence the posting here, as once I know the proper name /useage then I'll use google to try and find out more information ).... Thus any tips or pointers would be helpful (and I'm using a UNIX variant as OS)
4
2101
by: manochavishal | last post by:
Why would a signal handler cannot in general call standard library functions. I have read whats is said in Standard but needs an explaination on that as i couldn't uunderstand it. Thanx in advance
18
3920
by: Sven | last post by:
Hi, I found a strange behaviour when using the time() function from time.h. Sometimes when it is called, it does not show the correct time in seconds, but an initial value. This time seem to be the time when the program was started the first time. My platform is a DEC machine with Tru64 onboard. A possible explanation could be, that the time() function is called
2
2864
by: Marco | last post by:
Hi, In C, a signal handler function has only one parameter, that is signal number. But in Python(import signal), a signal handler function has two parameters, the first is signal number, the second is "frame"? What is "frame", please? Thank you!
1
2444
by: stalex | last post by:
Hi all, I wrote the following code since I want to try using a decorator to install signal handler: ## The test.py script ################# import os import time import signal
0
1722
by: comedeyboy19 | last post by:
Hi! i am writing a program in C that is a reservation maker. it supposed to ask if you wanna get first class or business class, and rest i have to finish. seats 1-5 are for first class, and seats 6-10 are for economy class. the probelm is that when seats 1-5 are full its supposed to ask if you wanna get a seat in economy and vice-versa. but everytime i get to seat 5 i get the error: Airline has exited due to signal 11 (SIGSEGV). can...
10
2149
by: Udai Kiran | last post by:
Hi all Iam having trouble with signal handler. Where will the execution return after invoking a signal handler when that particular signal is recieved? will return to the point where we register the signal? The following code is recieveing recursive signals. 2 #include <stdio.h> 3 #include <stdlib.h> 4 #include <unistd.h> 5
9
5838
by: thagor2008 | last post by:
Is the behaviour of throwing exceptions in a unix signal handler defined? eg: void sighandler(int sig) { ... do something throw myobj; }
0
9484
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10157
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10097
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9957
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8983
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7505
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6742
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5518
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4055
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.