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:
and here is how I am assigning it:
I do this right at the beginning of the code.
Now if I give it SIGINT, the function gets called and I get the correct output on screen - but only once. The second time that I give it ctrl-C, the shell exits.
Should I be doing anything else in the handler to allow for subsequent trapping of SIGINT?
I am working on HP-UX 11.11 PA-RISC.
Last edited by blowtorch; 10-07-2005 at 05:11 PM..
Reason: to add OS info
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)
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)
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)
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)
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)
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)
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)
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)
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
LEARN ABOUT DEBIAN
stsignal
stsignal(3) ShapeTools Toolkit Library stsignal(3)NAME
stCatchSigs, stInterruptAction, stQuitAction, stTermAction, stCleanup, stExit - signal handling
SYNOPSIS
#include <config.h>
#include <sttk.h>
void stCatchSigs (void);
Sfunc_t(*stInterruptAction)();
Sfunc_t(*stQuitAction)();
Sfunc_t(*stTermAction)();
void stCleanup (void);
void stExit (int exitCode);
DESCRIPTION
stCatchSigs activates a number of interrupt handlers, defined internally in the ShapeTools toolkit library. Interrupt handlers are defined
for the signals SIGINT, SIGQUIT, SIGFPE, SIGBUS, SIGSEGV, and SIGTERM. All interrupt handlers, except the one for SIGINT, cause program
termination after having done some cleanup work. The cleanup consists of removing all temporary files by calling stRmRegisteredFiles(3).
Some of the signal handlers are capable to execute functions defined by the application, while handling the interrupt. This mechanism is
activated by assigning a functions address to the appropriate variable. The following is a complete List.
Signal Variable
SIGINT stInterruptAction
SIGQUIT
stQuitAction
SIGTERM
stTermAction
stCleanup calls stRmRegisteredFiles(3) to remove all temporary files and the AtFS function af_cleanup(3) that orders AtFS's affairs.
stExit does the same as stCleanup and additionally end the program execution returning exitCode.
SEE ALSO
signal (3), stRmRegisteredFiles(3), af_cleanup(3).
sttk-1.7 Thu Jun 24 17:43:32 1993 stsignal(3)