Files
shell/helpers/traps.sh
2025-02-08 13:23:32 +08:00

22 lines
592 B
Bash

#!/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
}