03-17-2010
@jim mcnamara
Thank you for the explanation.
It means the same instruction which would have caused trouble keeps on getting to the execution point and OS alerts me infinite times.
So , this would be the case for all SIGSEGV/SIGBUS cases. Then can anyone tell me what could be the best possible algorithm to handle these types of signals.
Would it be anything like
1. Check the reason for signal.
2. Alert user/ get information for debugging
2. Terminate execution from the signal handler itself.(if i return from sig handler, it means that i am eligible for another signal, isn't it?)
Regards,
Sree
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
AIX 4.3.3
I am trying to write a signal handler into a ksh shell script. I would like to capture the SIGTERM, SIGINT, and the SIGTSTP signals, print out a message to the terminal, and continue executing the script. I have found a way to block the signals:
#! /bin/ksh
SIGTERM=15
SIGINT=2... (2 Replies)
Discussion started by: jalburger
2 Replies
2. Programming
Hi,
I have an c++ application which uses the function fork and execvp().
The parent does not wait until the child ends. The parents just creates children and let them do their stuff.
You can see the parent program as a batch-manager.
I have added a SIGCHLD handler to the program:
void... (3 Replies)
Discussion started by: jens
3 Replies
3. Programming
Hey guys,
I am trying to write a little shell, and was writing a signal handler to handle SIGINT (I am using 'stty intr ^C' and using ctrl-C to give SIGINT).
I wrote this signal handler: void handle_sigint()
{
write(2,"handling sigint\n",16);
write(1,"\nshell% ",8);
}
... (4 Replies)
Discussion started by: blowtorch
4 Replies
4. Programming
I have written a program to demonstrate a problem I have encountered when using BSD style asynchronous input using the O_ASYNC flag in conjunction with a real time interval timer sending regular SIGALRM signals to the program. The SIGIO handler obeys all safe practices, using only an atomic update... (8 Replies)
Discussion started by: stewartw
8 Replies
5. Programming
Is it ok to use exit() inside a signal handler?
I catch SIGUSR1 in a signal handler and I try to close a file and then exit. The result is inconsistent. Sometimes the process exit and sometimes it returns to the original state before the signal handler was invoked.
Perhaps exit is not legal in... (8 Replies)
Discussion started by: Tuvia
8 Replies
6. Programming
Hi,
I have a daq program that runs in an infinite loop until it receives SIGINT. A handler catches the signal and sets a flag to stop the while loop. After the loop some things have to be cleaned up.
The problem is that I want my main while loop to wait until the next full second begins, to... (2 Replies)
Discussion started by: soeckel
2 Replies
7. Shell Programming and Scripting
I have a problem with signal handlers not working.
I have a long 1000 line code and somehow this code for signal handling is not working:
$SIG{INT} = \&interrupt;
sub interrupt {
print STDERR "Caught a control c!\n";
exit; # or just about anything else you'd want to do
}
Any... (2 Replies)
Discussion started by: som.nitk
2 Replies
8. Shell Programming and Scripting
I was working on some Perl code that does signal handling and I came across this one liner and wasn't sure what it was doing.
local $SIG{__DIE__} = sub {$! = 2; die $_;};
I think the first part of the anonymous subroutine is setting $! to 2, but I am not sure what the second part is doing. ... (1 Reply)
Discussion started by: SFNYC
1 Replies
9. Programming
i m unble to execute code of
signal handler using
a) Wait b) Waitpid (1 Reply)
Discussion started by: madhura
1 Replies
10. Programming
Hello,
I'm writing some serial(UART) handler but have stuck on few issues, maybe anyone can help to show me what I'm doing wrong.
Basically I'm intending to write serial RX signal handler.
Application receives defined packages of data over serial which contains header and payload. Handler... (3 Replies)
Discussion started by: Lauris_k
3 Replies
SIGNAL(P) POSIX Programmer's Manual SIGNAL(P)
NAME
signal - signal management
SYNOPSIS
#include <signal.h>
void (*signal(int sig, void (*func)(int)))(int);
DESCRIPTION
Use of this function is unspecified in a multi-threaded process.
The signal() function chooses one of three ways in which receipt of the signal number sig is to be subsequently handled. If the value of
func is SIG_DFL, default handling for that signal shall occur. If the value of func is SIG_IGN, the signal shall be ignored. Otherwise, the
application shall ensure that func points to a function to be called when that signal occurs. An invocation of such a function because of a
signal, or (recursively) of any further functions called by that invocation (other than functions in the standard library), is called a
"signal handler".
When a signal occurs, and func points to a function, it is implementation-defined whether the equivalent of a:
signal(sig, SIG_DFL);
is executed or the implementation prevents some implementation-defined set of signals (at least including sig) from occurring until the
current signal handling has completed. (If the value of sig is SIGILL, the implementation may alternatively define that no action is
taken.) Next the equivalent of:
(*func)(sig);
is executed. If and when the function returns, if the value of sig was SIGFPE, SIGILL, or SIGSEGV or any other implementation-defined value
corresponding to a computational exception, the behavior is undefined. Otherwise, the program shall resume execution at the point it was
interrupted. If the signal occurs as the result of calling the abort(), raise(), kill(), pthread_kill(), or sigqueue() function, the
signal handler shall not call the raise() function.
If the signal occurs other than as the result of calling abort(), raise(), kill(), pthread_kill(), or sigqueue(), the behavior is unde-
fined if the signal handler refers to any object with static storage duration other than by assigning a value to an object declared as
volatile sig_atomic_t, or if the signal handler calls any function in the standard library other than one of the functions listed in Signal
Concepts . Furthermore, if such a call fails, the value of errno is unspecified.
At program start-up, the equivalent of:
signal(sig, SIG_IGN);
is executed for some signals, and the equivalent of:
signal(sig, SIG_DFL);
is executed for all other signals (see exec).
RETURN VALUE
If the request can be honored, signal() shall return the value of func for the most recent call to signal() for the specified signal sig.
Otherwise, SIG_ERR shall be returned and a positive value shall be stored in errno.
ERRORS
The signal() function shall fail if:
EINVAL The sig argument is not a valid signal number or an attempt is made to catch a signal that cannot be caught or ignore a signal that
cannot be ignored.
The signal() function may fail if:
EINVAL An attempt was made to set the action to SIG_DFL for a signal that cannot be caught or ignored (or both).
The following sections are informative.
EXAMPLES
None.
APPLICATION USAGE
The sigaction() function provides a more comprehensive and reliable mechanism for controlling signals; new applications should use sigac-
tion() rather than signal().
RATIONALE
None.
FUTURE DIRECTIONS
None.
SEE ALSO
Signal Concepts , exec() , pause() , sigaction() , sigsuspend() , waitid() , the Base Definitions volume of IEEE Std 1003.1-2001, <sig-
nal.h>
COPYRIGHT
Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1, 2003 Edition, Standard for Information Technol-
ogy -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE
and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained
online at http://www.opengroup.org/unix/online.html .
IEEE
/The Open Group 2003 SIGNAL(P)