Google
Web tarasdom.com

 

UNIX signals


Number KSH Name Description
0 EXIT This number does not correspond to a real signal, but the corresponding trap is executed before script termination.
1 HUP hangup
2 INT The interrupt signal typically is generated using the DEL or the ^C key
3 QUIT The quit signal is typically generated using the ^[ key. It is used like the INT signal but explicitly requests a core dump.
4 ILL illegal instruction
5 TRAP trace trap
6 IOT IOT instruction
7 EMT EMT instruction
8 FPE floating point exception
9 KILL cannot be caught or ignored
10 BUS bus error
11 SEGV segmentation violation
12 SYS bad argument to system call
13 PIPE generated if there is a pipeline without reader to terminate the writing process(es)
14 ALRM alarm clock
15 TERM generated to terminate the process gracefully
16 USR1 user defined signal 1
17 USR2 user defined signal 2
18 CLD child process died
19 PWR restart after power failure
- DEBUG KSH only: This is no signal, but the corresponding trap code is executed before each statement of the script.

Usage:
KSH script
Use "trap" function to catch the signals in shell script:

print -n "Enter Your password:"
stty_orig=`stty -g`
trap "stty ${stty_orig}; exit" 1 2 3 15
stty -echo >&- 2>&-
read PASS 
stty ${stty_orig} >&- 2>&-
trap 1 2 3 15
print 
Perl

# Just ignore the interruption
$SIG{'INT'} = 'IGNORE'; 
# ...some code...
$SIG{'INT'} = 'DEFAULT'; 
################
# Complex processing
sub INT_handler {
 # some actions, ie writing to the log
 exit(0);
}
$SIG{'INT'} = 'INT_handler';

See also

©
Page was modified 23.07.2006