10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
I am having issues with trap not working inside a script. I am currently trying this on a Knoppix system V 5.1. What I would like to happen is when I press control c, a message gets echoed and the script is ended. For example:
#! /bin/bash
trap "echo CTRL c was pressed ; break" SIGINT... (11 Replies)
Discussion started by: Basherrr
11 Replies
2. UNIX for Advanced & Expert Users
Hi All,
The problem statement is as below:
Problem: A process (exe) is getting executed in background. The output of this process is getting logged in a file. After successfully running for some time the process gets terminated. In the log file following is present:
^M[7m Interrupt ^M[27m... (8 Replies)
Discussion started by: Praty.27
8 Replies
3. UNIX for Dummies Questions & Answers
I was wondering about following. If I have set of 3 signals. And they are all blocked.Now at some point in the program the set is unblocked. Which signal will be delivered first.This is my set....SIGTSTP,SIGQUIT,SIGINT.When I added them in the set and unblock them I did it in following order...
... (1 Reply)
Discussion started by: joker40
1 Replies
4. UNIX for Dummies Questions & Answers
I know how to add signal to a set. But what if I want to add 2 or 3 signals to the set.
I know I can use sigaddset (&set,SIGBUS)....but what if I want to add SIGBUS and SIGALRM at once. Do i have to do it like this..
sigaddset (&set,SIGBUS);
sigaddset (&set,SIGALRM);
Is there another way to... (0 Replies)
Discussion started by: joker40
0 Replies
5. UNIX for Dummies Questions & Answers
I have following problem with this code..
First time trough the main loop.....
perror gives ....blocked signal:success(all other times gives illlegal seek)
Should every time trought the main loop be success??
And the perror otside of main loop...didn't change mask:success
That line of code... (2 Replies)
Discussion started by: joker40
2 Replies
6. UNIX for Dummies Questions & Answers
I am having trouble with folowing
sigset_t s; // now s represents set of signals
sigemptyset(&s) ; // initialize this set and exclude all the signals from it.is it empty?
sigaddset(&s,SIGILL);//this set containts only SIGILL signal
sigprocmask(SIG_BLOCK,&s,NULL);//lost on this one
Can... (3 Replies)
Discussion started by: joker40
3 Replies
7. Programming
Hi,
In our program, we are using SIGTERM and i tired to put break point in this function. But my debuger is unable to brake at that point.
I am working on Mac X and using XCode.
Thanks (1 Reply)
Discussion started by: Saurabh78
1 Replies
8. Programming
How can use signals in a C program If i want a child program to signal it's parent program that it(child) program has completed the task that it was assigned.:confused: (2 Replies)
Discussion started by: kapilv
2 Replies
9. UNIX for Dummies Questions & Answers
(posted this in the scripting forum as well, but figured it should go here) So, what's going on is this:
For our program, we had to create our own shell, and if the user pressed ctrl-c just at the cmdline, then this signal would be ignored, but if there is a foreground process running, let's... (0 Replies)
Discussion started by: blind melon
0 Replies
10. Programming
does the way of handling, interrupting signals in HP-UX same as that of solaris. If there is difference than what it is.?:confused: (1 Reply)
Discussion started by: kapilv
1 Replies
sigfpe(3C) Standard C Library Functions sigfpe(3C)
NAME
sigfpe - signal handling for specific SIGFPE codes
SYNOPSIS
#include <floatingpoint.h>
#include <siginfo.h>
sigfpe_handler_type sigfpe(sigfpe_code_type code,
sigfpe_handler_type hdl);
DESCRIPTION
The sigfpe() function allows signal handling to be specified for particular SIGFPE codes. A call to sigfpe() defines a new handler hdl for
a particular SIGFPE code and returns the old handler as the value of the function sigfpe(). Normally handlers are specified as pointers to
functions; the special cases SIGFPE_IGNORE, SIGFPE_ABORT, and SIGFPE_DEFAULT allow ignoring, dumping core using abort(3C), or default han-
dling respectively. Default handling is to dump core using abort(3C).
The code argument is usually one of the five IEEE754-related SIGFPE codes:
FPE_FLTRES fp_inexact - floating-point inexact result
FPE_FLTDIV fp_division - floating-point division by zero
FPE_FLTUND fp_underflow - floating-point underflow
FPE_FLTOVF fp_overflow - floating-point overflow
FPE_FLTINV fp_invalid - floating-point invalid operation
Three steps are required to intercept an IEEE754-related SIGFPE code with sigfpe():
1. Set up a handler with sigfpe().
2. Enable the relevant IEEE754 trapping capability in the hardware, perhaps by using assembly-language instructions.
3. Perform a floating-point operation that generates the intended IEEE754 exception.
The sigfpe() function never changes floating-point hardware mode bits affecting IEEE754 trapping. No IEEE754-related SIGFPE signals will
be generated unless those hardware mode bits are enabled.
SIGFPE signals can be handled using sigfpe(), sigaction(2) or signal(3C). In a particular program, to avoid confusion, use only one of
these interfaces to handle SIGFPE signals.
EXAMPLES
Example 1 Example Of A User-Specified Signal Handler
A user-specified signal handler might look like this:
#include <floatingpoint.h>
#include <siginfo.h>
#include <ucontext.h>
/*
* The sample_handler prints out a message then commits suicide.
*/
void
sample_handler(int sig, siginfo_t *sip, ucontext_t *uap) {
char *label;
switch (sip->si_code) {
case FPE_FLTINV: label = "invalid operand"; break;
case FPE_FLTRES: label = "inexact"; break;
case FPE_FLTDIV: label = "division-by-zero"; break;
case FPE_FLTUND: label = "underflow"; break;
case FPE_FLTOVF: label = "overflow"; break;
default: label = "???"; break;
}
fprintf(stderr,
"FP exception %s (0x%x) occurred at address %p.
",
label, sip->si_code, (void *) sip->si_addr);
abort();
}
and it might be set up like this:
#include <floatingpoint.h>
#include <siginfo.h>
#include <ucontext.h>
extern void sample_handler(int, siginfo_t *, ucontext_t *);
main(void) {
sigfpe_handler_type hdl, old_handler1, old_handler2;
/*
* save current fp_overflow and fp_invalid handlers; set the new
* fp_overflow handler to sample_handler() and set the new
* fp_invalid handler to SIGFPE_ABORT (abort on invalid)
*/
hdl = (sigfpe_handler_type) sample_handler;
old_handler1 = sigfpe(FPE_FLTOVF, hdl);
old_handler2 = sigfpe(FPE_FLTINV, SIGFPE_ABORT);
...
/*
* restore old fp_overflow and fp_invalid handlers
*/
sigfpe(FPE_FLTOVF, old_handler1);
sigfpe(FPE_FLTINV, old_handler2);
}
FILES
/usr/include/floatingpoint.h
/usr/include/siginfo.h
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|MT-Level |Safe |
+-----------------------------+-----------------------------+
SEE ALSO
sigaction(2), abort(3C), signal(3C), attributes(5), floatingpoint.h(3HEAD)
DIAGNOSTICS
The sigfpe() function returns (void(*)())-1 if code is not zero or a defined SIGFPE code.
SunOS 5.11 4 May 2004 sigfpe(3C)