Beispiele zum Blogpost.
This commit is contained in:
10
teil25/notrap
Executable file
10
teil25/notrap
Executable file
@@ -0,0 +1,10 @@
|
||||
#! /usr/bin/bash
|
||||
|
||||
|
||||
touch /tmp/testfile
|
||||
|
||||
sleep 10
|
||||
echo "Ende der Arbeit"
|
||||
|
||||
rm /tmp/testfile
|
||||
|
||||
23
teil25/on-exit.sh
Executable file
23
teil25/on-exit.sh
Executable file
@@ -0,0 +1,23 @@
|
||||
#! /usr/bin/bash
|
||||
|
||||
on_exit() {
|
||||
echo "Programmende signalisiert."
|
||||
}
|
||||
|
||||
on_debug() {
|
||||
echo "debug handler"
|
||||
echo "[DEBUG] counter=${counter}"
|
||||
}
|
||||
|
||||
trap on_exit exit
|
||||
trap on_debug debug
|
||||
|
||||
|
||||
sleep 10
|
||||
#counter=0
|
||||
#while true; do
|
||||
# let counter++
|
||||
# echo "running..."
|
||||
#done
|
||||
|
||||
|
||||
15
teil25/sighup.sh
Executable file
15
teil25/sighup.sh
Executable file
@@ -0,0 +1,15 @@
|
||||
#! /usr/bin/bash
|
||||
|
||||
on_hup() {
|
||||
echo "hup handler"
|
||||
}
|
||||
|
||||
trap on_info SIGHUP
|
||||
|
||||
my_pid=$!
|
||||
echo "${my_pid}"
|
||||
while true; do
|
||||
sleep 1
|
||||
done
|
||||
|
||||
|
||||
15
teil25/trap
Executable file
15
teil25/trap
Executable file
@@ -0,0 +1,15 @@
|
||||
#! /usr/bin/bash
|
||||
|
||||
cleanup() {
|
||||
echo "Programmende signalisiert."
|
||||
rm /tmp/testfile
|
||||
}
|
||||
|
||||
trap cleanup exit
|
||||
touch /tmp/testfile
|
||||
|
||||
trap - exit
|
||||
sleep 10
|
||||
echo "Ende der Arbeit"
|
||||
|
||||
|
||||
11
teil25/trap2
Executable file
11
teil25/trap2
Executable file
@@ -0,0 +1,11 @@
|
||||
#! /usr/bin/bash
|
||||
|
||||
|
||||
trap "echo vorbei" SIGINT
|
||||
|
||||
touch /tmp/testfile
|
||||
|
||||
sleep 10
|
||||
echo "Ende der Arbeit"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user