fix: add EXIT trap to ensure encryption flag and temp files are cleaned up on crash
This commit is contained in:
@@ -167,6 +167,8 @@ usage() {
|
||||
clean_up() {
|
||||
|
||||
# Perform program exit housekeeping
|
||||
# Clear EXIT trap first so that the exit below does not fire it again.
|
||||
trap - EXIT
|
||||
[[ -n "$restore_php_file" ]] && rm -f "$restore_php_file" 2> /dev/null
|
||||
rm -rf "$LOCK_DIR"
|
||||
blank_line
|
||||
@@ -781,7 +783,9 @@ if mkdir "$LOCK_DIR" 2> /dev/null ; then
|
||||
|
||||
# - Remove lockdir when the script finishes, or when it receives a signal
|
||||
# -
|
||||
trap clean_up SIGHUP SIGINT SIGTERM
|
||||
# Trap signals AND normal/abnormal exit so that temp files and the
|
||||
# lock directory are always removed — even on an unexpected crash.
|
||||
trap 'clean_up 1' SIGHUP SIGINT SIGTERM EXIT
|
||||
|
||||
else
|
||||
|
||||
|
||||
Reference in New Issue
Block a user