diff --git a/lgsm/functions/core_exit.sh b/lgsm/functions/core_exit.sh index bfef50e7b..2671bb7a2 100644 --- a/lgsm/functions/core_exit.sh +++ b/lgsm/functions/core_exit.sh @@ -23,6 +23,8 @@ if [ -n "${exitcode}" ]&&[ "${exitcode}" != "0" ]; then fn_script_log_warn "${function_selfname} exiting with code: ${exitcode}" fi fn_exit_dev_debug + # remove trap. + trap - INT exit ${exitcode} elif [ -n "${exitbypass}" ]; then unset exitbypass @@ -30,6 +32,8 @@ else fn_script_log_pass "${function_selfname} exiting with code: ${exitcode}" exitcode=0 fn_exit_dev_debug + # remove trap. + trap - INT exit ${exitcode} fi diff --git a/lgsm/functions/core_functions.sh b/lgsm/functions/core_functions.sh index 22ca78f4f..848c1f588 100644 --- a/lgsm/functions/core_functions.sh +++ b/lgsm/functions/core_functions.sh @@ -88,6 +88,11 @@ functionfile="${FUNCNAME}" fn_fetch_core_dl } +core_trap.sh(){ +functionfile="${FUNCNAME}" +fn_fetch_core_dl +} + core_messages.sh(){ functionfile="${FUNCNAME}" fn_fetch_core_dl @@ -471,6 +476,8 @@ functionfile="${FUNCNAME}" fn_fetch_function } +# Calls the global Ctrl-C trap +core_trap.sh # Calls on-screen messages core_messages.sh diff --git a/lgsm/functions/core_trap.sh b/lgsm/functions/core_trap.sh new file mode 100644 index 000000000..f56e329c9 --- /dev/null +++ b/lgsm/functions/core_trap.sh @@ -0,0 +1,14 @@ +#!/bin/bash +# LGSM core_trap.sh function +# Author: Daniel Gibbs +# Website: https://gameservermanagers.com +lgsm_version="210516" + +# Description: handles ctrl-C trap to give an exitcode. + +fn_exit_trap(){ + core_exit.sh +} + +# trap to remove lockfile on quit. +trap fn_exit_trap INT \ No newline at end of file