-
Notifications
You must be signed in to change notification settings - Fork 1
/
signal-trap.sh
executable file
·40 lines (37 loc) · 1.16 KB
/
signal-trap.sh
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
. ' =============================================================================
| Week-2: Trapping Signals
|
| Author: Ahmer Malik
| Language: Shell Script
|
| Company: Techknox Systems
|
|
+-----------------------------------------------------------------------------
|
| Description: This scripts continuously prints/write a number in a text file untill it traps signals SIGINT and SIGTERM and ERR.
|
| Input: Nothing
|
|
| Output: Prints numbers with the increment of 1 in a text file "counter.txt" in your home directory.
| Print "The signal has been trapped!!!" on terminal if SIGINT or SIGTERM interrupterd & then exit
| Print "Error has been trapped!!!!:" with ERR type on terminal, if any command is used wrong.
|
| Known Bugs: There are no known bugs remaining in this program.
|
+===========================================================================*/
'
trap "echo The signal has been trapped!!!; exit" SIGINT SIGTERM
trap "echo Error has been trapped!!!!: " ERR
echo "pid is $$"
echo $$ > kill_process_ID.txt
i=1
ls-l
while :
do
sleep 10
echo $i
echo $i > counter.txt
let i=i+1
done