Sponsored Content
Top Forums Programming Usage of exit() inside a signal handler Post 302215720 by jim mcnamara on Thursday 17th of July 2008 04:59:05 AM
Old 07-17-2008
You should not call stdC library functions like fwrite in a signal handler. They are not atomic, so they may not complete in the event of multiple signals. Try write().
 

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

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

6. Shell Programming and Scripting

Perl - Problems with Signal Handler

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

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
sigvec(2)							System Calls Manual							 sigvec(2)

NAME
sigvec - Provides a compatibility interface to the sigaction() function SYNOPSIS
#include <sys/signal.h> int sigvec ( int signal, struct sigvec *in_vec, struct sigvec *out_vec ); PARAMETERS
Specifies the signal number. Points to a sigvec() structure that specifies the action to be taken when the specified signal is delivered, the mask to be used when calling the signal handler, and the flags that modify signal behavior. Points to a sigvec() structure that is set to the previous signal action state on successful return from the sigvec() function. DESCRIPTION
The sigvec() function is provided for compatibility to old UNIX systems; its function is a subset of that available with the sigaction() function. Like the sigaction() function, the sigvec() function allows the user to set the action to take upon the receipt of a signal and to specify a signal handler mask to block signals before calling the signal handler. However, only signals with values 1 to 31 can be masked on entry to a signal-handler set up with the sigvec() function. The sigvec() structure has the following members: void (*sv_handler)( ); int sv_mask; int sv_flags; The sv_handler field specifies the action for the signal, and can be SIG_DFL, SIG_IGN, or the address of a signal handler function. See the sigaction() function for a detailed description of the signal actions. The sv_mask field specifies a mask which specifies signals to block (in addition to any signals already blocked at time of delivery) when the signal handler function is called for the signal. Signal i is blocked if the i-th bit of the mask is set. Only signals with values 1 to 31 can be masked with the sigvec() function. The sv_flags field contains flags that further specify signal behavior. If SV_ONSTACK is set, the signal handler runs on the signal stack specified by the sigstack() function; otherwise, the signal handler runs on the stack of the process receiving the signal. If SV_INTERRUPT is set, a system call that is interrupted by signal returns a value of -1 with errno set to [EINTR]; otherwise, a system call interrupted by signal is restarted. If the value of the in_vec parameter is a null pointer, then the signal handler information is not set. If the value of the out_vec parame- ter is null, then the previous signal handler information is not returned. Once a signal handler is assigned, it remains assigned until another call to the sigvec(), signal(), sigaction(), or exec function is made. NOTES
The sigvec() function is provided for compatibility only, and its use is not recommended. Programs should use the sigaction() function instead. The sigvec() function does not check the validity of the sv_handler field pointer. If it points to a location outside of the process address space, the process receives a memory fault when the system attempts to call the signal handler. If the sv_handler field points to anything other than a function, the results are unpredictable. The signal-handler function can be declared as follows: void handler ( int signal ); RETURN VALUES
Upon successful completion, a value of 0 (zero) is returned. If the sigvec() function fails, a value of -1 is returned and errno is set to indicate the error. ERRORS
If the sigvec() function fails, no new signal handler is installed and errno may be set to one of the following values: The in_vec or out_vec parameter points to a location outside of the process' address space. The signal parameter is not a valid signal number. An attempt was made to ignore or supply a handler for the SIGKILL signal. RELATED INFORMATION
Functions: kill(2), ptrace(2), sigaction(2), sigblock(2), sigpause(3), sigstack(2) delim off sigvec(2)
All times are GMT -4. The time now is 05:27 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy