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 13 17720
In article <11************ **********@o13g 2000cwo.googleg roups.com>,
<va******@redif fmail.com> wrote: 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); .......... .......... }
You cannot use printf() inside a signal handler.
In standard C, other than calling exit, resetting the signal handler,
or a *very* small number of other things, all you can do is set
a volatile variable of sig_atomic_t .
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
What evidence have you found that the handler is not catching SIGSEGV ?
If it is just that the printf() are not occuring, then you might
be encountering the restrictions on what you can do in a handler.
--
All is vanity. -- Ecclesiastes
Walter Roberson wrote: You cannot use printf() inside a signal handler.
In standard C, other than calling exit, resetting the signal handler, or a *very* small number of other things, all you can do is set a volatile variable of sig_atomic_t .
Could you please tell me about restrictions on signal handlers or where
I can find more info about restrictions on signal handlers?
Thanks,
Madhav.
Madhav said: Walter Roberson wrote: You cannot use printf() inside a signal handler.
In standard C, other than calling exit, resetting the signal handler, or a *very* small number of other things, all you can do is set a volatile variable of sig_atomic_t . Could you please tell me about restrictions on signal handlers
He just did.
or where I can find more info about restrictions on signal handlers?
That's the whole thing.
--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999 http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
> In standard C, other than calling exit, resetting the signal handler, or a *very* small number of other things, all you can do is set a volatile variable of sig_atomic_t .
Can I invoke longjmp in signal handler?
Actually, In our project we have to return status to the scheduler(Some
what like scheduler) which will execute our program. The scheduler is
in JAVA. The values I should return is 0 (if everything is fine) or
50(warning, If not a very serious error has occurred) or 99(If some
serious error has occurred like segmentation fault).I was thinking to
use longjmp inside signal handler and jump to main and then return
appropriate error status. What evidence have you found that the handler is not catching SIGSEGV ?
Programming terminated due to segmentation fault. va******@rediff mail.com said: In standard C, other than calling exit, resetting the signal handler, or a *very* small number of other things, all you can do is set a volatile variable of sig_atomic_t . Can I invoke longjmp in signal handler?
Not with well-defined behaviour, no.
--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999 http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
Richard Heathfield wrote: va******@rediff mail.com said:
In standard C, other than calling exit, resetting the signal handler, or a *very* small number of other things, all you can do is set a volatile variable of sig_atomic_t . Can I invoke longjmp in signal handler?
Not with well-defined behaviour, no.
Is it possible to return certain value to the calling program from
signal handler?My aim is to exit gracefully and to return the
predefined values to the scheduler, which invokes my program.Note that
scheduler is coded using JAVA.
OK, let me put it in a better eay. This is what happens in our project
JAVA progam calls list of C programs. C programs should return the
status(0, 50 or 100) to JAVA. I somehow want to return the status to
JAVA program if there is a segmentation fault. I don't want to exit
from signal handler
.. va******@rediff mail.com said: Richard Heathfield wrote: va******@rediff mail.com said:
>> In standard C, other than calling exit, resetting the signal handler, >> or a *very* small number of other things, all you can do is set >> a volatile variable of sig_atomic_t . >> > Can I invoke longjmp in signal handler?
Not with well-defined behaviour, no. Is it possible to return certain value to the calling program from signal handler?
No. Signal handlers have the form void handler(int); and thus do not return
a value. You can, however, use the signal handler to modify a file scope
object of type sig_atomic_t.
--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999 http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
Richard Heathfield wrote: va******@rediff mail.com said:
Richard Heathfield wrote: va******@rediff mail.com said:
> In standard C, other than calling exit, resetting the signal handler, > or a *very* small number of other things, all you can do is set > a volatile variable of sig_atomic_t . > Can I invoke longjmp in signal handler? Not with well-defined behaviour, no. Is it possible to return certain value to the calling program from signal handler?
No. Signal handlers have the form void handler(int); and thus do not return a value. You can, however, use the signal handler to modify a file scope object of type sig_atomic_t.
I think he meant return a value to the program that invoked his C
program, not return a value in to his program. If I read him right, then
calling exit from within the signal handler might be the way to go,
although whether doing exit(99) is valid is system dependant.
--
Flash Gordon
Living in interesting times.
Although my email address says spam, it is real and I read it.
Walter Roberson wrote: In article <11************ **********@o13g 2000cwo.googleg roups.com>, <va******@redif fmail.com> wrote:
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); .......... .......... }
You cannot use printf() inside a signal handler.
In standard C, other than calling exit, resetting the signal handler, or a *very* small number of other things, all you can do is set a volatile variable of sig_atomic_t .
Calling exit() in a signal handler is impermissible.
Perhaps you mean _Exit(), a function introduced in C99;
see 7.14.1.1/5. Handlers for signals that were generated
by raise() or abort() are not subject to these restrictions;
handlers for all other signals must respect them.
--
Eric Sosman es*****@acm-dot-org.invalid This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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):
|
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)
|
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
|
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
|
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!
| |
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
|
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...
|
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
|
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;
}
|
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,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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...
|
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,...
|
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();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |