signal traps for endgame cleanups

This commit is contained in:
Jaromil 2014-08-14 09:58:15 +02:00
parent cfe04a6bee
commit 9d718d0ebb

21
tomb
View File

@ -73,6 +73,23 @@ PATH+=:/sbin:/usr/sbin
# {{{ Safety functions
endgame() {
# here clear all temp files and flush all pipes
_verbose "Signal trap: $1"
unset tomb_secret
}
# trap functions for the endgame event
TRAPINT() { endgame INT }
TRAPEXIT() { endgame EXIT }
TRAPHUP() { endgame HUP }
TRAPQUIT() { endgame QUIT }
TRAPABRT() { endgame ABORT }
TRAPKILL() { endgame KILL }
TRAPPIPE() { endgame PIPE }
TRAPTERM() { endgame TERM }
TRAPSTOP() { endgame STOP }
_have_shm() {
# Check availability of 1MB of SHM
_verbose "_have_shm 0 We need only 1 MB of RAM."
@ -1249,6 +1266,7 @@ dig_tomb() {
chown $_uid:$_gid "${tombdir}/${tombfile}"
_verbose "Data dump using ${DD[1]} from /dev/urandom"
${=DD} if=/dev/urandom bs=1048576 count=${tombsize} of=${tombdir}/${tombfile}
if [ $? = 0 -a -e ${tombdir}/${tombfile} ]; then
@ -2313,8 +2331,8 @@ slam_tomb() {
# }}} - Tomb close
# {{{ Main routine
main() {
local -A subcommands_opts
### Options configuration
@ -2580,6 +2598,7 @@ EOF
# {{{ Run
check_bin
main $@
ret=$?
if [[ $ret != 0 ]]; then #this "if" seems useless, but avoid source tomb source from exiting