Sponsored Content
Top Forums Shell Programming and Scripting Perl - Problems with Signal Handler Post 302345173 by jim mcnamara on Tuesday 18th of August 2009 03:25:53 PM
Old 08-18-2009
Something else is blocking SIGINT? Or maybe I better ask - what does 'not working mean'?
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

shell script signal handler

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

signal handler for SIGCHLD

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

signal handler problems

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

Runaway SIGALRM signal handler

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

Usage of exit() inside a signal handler

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

Problem with signal handler and interrupted system call

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. Programming

Signal Handler Hangs

Hi, I have a problem with signal handler algorithm in linux. My code is hanging ( It is continuously looping inside the signal handler) . I am pasting my code here... Please provide me some help regarding this. I googled many places and wrote this code.. but doesnt seem to be working without... (6 Replies)
Discussion started by: sree_ec
6 Replies

8. Shell Programming and Scripting

Perl Signal Handler

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

problem in doing coding of signal handler

i m unble to execute code of signal handler using a) Wait b) Waitpid (1 Reply)
Discussion started by: madhura
1 Replies

10. Programming

Serial port signal(IRQ) handler (using C)

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
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.10 4 May 2004 sigfpe(3C)
All times are GMT -4. The time now is 09:38 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy