signal handler routine
frnds,
I want to catch all the signals which I get. for example, Code:
or may be I am wrong, then is there any special method to implement this ? thnx in advance... |
You cannot block all signals, SIGKILL for example.
You have to invoke signal once for each separate signal. Next, printf() may cause problems in your signal handler. Most of the standard library functions have problems because they can be interrupted by yet another signal. Try using write() instead. |
Also, the second argument to signal should be sighandler, not signum.
|
thnx jim mcnamara
thnx for ur replay but the problem is still there.. if i want to catch all the signals except(non catchable signals), how can I achive this ?? is there any trick ?? |
Here's a demonstration program that catches an interrupt signal; e.g., when a user tries to abort a program with CTRL-C or the delete key. By use setsig, sigsetjmp and siglongjmp the program cannot be killed by flooding it with interrupt signals (this is the sort of thing that you'd use to clean up files when an interrupt is received):
Code:
#include <stdio.h> |
thnx tronayne
ur code is very much helpfull to me.. thnx once again... |
a quick scan of the header files (/usr/include/asm/signal.h & /usr/include/bits/signum.h) does not reveal a single macro that specifies all catch-able signals.
however, i suggest you write a loop that sets them all in just a couple lines of code. here's some psuedo code: for ( i = 0; i < 32; i++ ) { signal( i, sighandler ); } don't know what the system will do if you try to set a signal handler for a signal that cannot be caught. |
thnx jdiggitydogg,,,,,,,,it seems also a usefull trick
|
All times are GMT -5. The time now is 10:37 AM. |