diff --git a/teil25/notrap b/teil25/notrap new file mode 100755 index 0000000..a198384 --- /dev/null +++ b/teil25/notrap @@ -0,0 +1,10 @@ +#! /usr/bin/bash + + +touch /tmp/testfile + +sleep 10 +echo "Ende der Arbeit" + +rm /tmp/testfile + diff --git a/teil25/on-exit.sh b/teil25/on-exit.sh new file mode 100755 index 0000000..5426a8e --- /dev/null +++ b/teil25/on-exit.sh @@ -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 + + diff --git a/teil25/sighup.sh b/teil25/sighup.sh new file mode 100755 index 0000000..900500c --- /dev/null +++ b/teil25/sighup.sh @@ -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 + + diff --git a/teil25/trap b/teil25/trap new file mode 100755 index 0000000..591f40d --- /dev/null +++ b/teil25/trap @@ -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" + + diff --git a/teil25/trap2 b/teil25/trap2 new file mode 100755 index 0000000..3ec24d4 --- /dev/null +++ b/teil25/trap2 @@ -0,0 +1,11 @@ +#! /usr/bin/bash + + +trap "echo vorbei" SIGINT + +touch /tmp/testfile + +sleep 10 +echo "Ende der Arbeit" + +