new traps example
This commit is contained in:
21
helpers/traps.sh
Normal file
21
helpers/traps.sh
Normal file
@@ -0,0 +1,21 @@
|
||||
#!/usr/bin/env bash
|
||||
#TODO source basic.sh
|
||||
#TODO source args-parser/args.sh
|
||||
|
||||
########################################################
|
||||
# Trap usage examples
|
||||
########################################################
|
||||
|
||||
# for sig in SIGHUP SIGINT SIGQUIT SIGABRT SIGKILL SIGTERM SIGTSTP; do
|
||||
# # shellcheck disable=SC2064
|
||||
# trap "set +x && echo && echo && echo '*** Прервано сигналом $sig, остановка ***' && exit" $sig
|
||||
# done
|
||||
|
||||
for sig in SIGHUP SIGINT SIGQUIT SIGABRT SIGKILL SIGTERM SIGTSTP; do
|
||||
trap "myfunc" $sig
|
||||
done
|
||||
|
||||
myfunc() {
|
||||
echo "trapped!"
|
||||
exit
|
||||
}
|
||||
Reference in New Issue
Block a user