-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsignal_and_traps.sh
More file actions
50 lines (40 loc) · 2.01 KB
/
Copy pathsignal_and_traps.sh
File metadata and controls
50 lines (40 loc) · 2.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#! /bin/bash
# signals and traps statement in shell scripting
echo "pid is $$" # dollar dollar symbol is used to print the pid (processor id) of script itself
while (( COUNT < 10 ))
do
sleep 10 # print in every 10 sec upto 10 then exit the script
(( COUNT ++ ))
echo $COUNT
done
exit 0
<<com
SIGNALS
ctrl c is called the interupt signal ( SIGINT ) in terms of signal
ctrl Z is suspend signal (SIGTSTP) in terms of signal
kill -9 processor_id or kill pid
The trap command provides the script to captures an interrupt (signal) and then clean it up within the script.
First the signals described in the original POSIX.1-1990 standard.
Signal Value Action Comment
-------------------------------------------------------------------------------------------
SIGHUP 1 Term Hangup detected on controlling terminal
or death of controlling process
SIGINT 2 Term Interrupt from keyboard
SIGQUIT 3 Core Quit from keyboard
SIGILL 4 Core Illegal Instruction
SIGABRT 6 Core Abort signal from abort(3)
SIGFPE 8 Core Floating-point exception
SIGKILL 9 Term Kill signal
SIGSEGV 11 Core Invalid memory reference
SIGPIPE 13 Term Broken pipe
SIGALRM 14 Term Timer signal from alarm(2)
SIGTERM 15 Term Termination signal
SIGUSR1 30,10,16 Term User-defined signal 1
SIGUSR2 31,12,17 Term User-defined signal 2
SIGCHLD 20,17,18 Ign Child stopped or terminated
SIGCONT 19,18,25 Cont Continue if stopped
SIGSTOP 17,19,23 Stop Stop process
SIGTSTP 18,20,24 Stop Stop typed at terminal
SIGTTIN 21,21,26 Stop Terminal input for background process
SIGTTOU 22,22,27 Stop Terminal output for background process
com