From: Matthias Kruk Date: Sat, 26 Nov 2022 03:41:25 +0000 (+0900) Subject: include/inst: Allow terminated instances to be cleaned up properly X-Git-Url: https://git.corax.cc/?a=commitdiff_plain;h=78573c48aad68170a197bf7a81af51309fc5c06e;p=toolbox include/inst: Allow terminated instances to be cleaned up properly The signal handler that is registered by `_inst_run()' catches the EXIT and QUIT signals, which causes the handler to be executed one more time before the process ends. The semaphore that the handler will attempt to manipulate at that point will have already been removed, causing the handler to end up in an infinite loop. This commit changes the trap call so that the EXIT and QUIT signals are not handled, preventing the signal handler from being executed more than once. --- diff --git a/include/inst.sh b/include/inst.sh index c96e489..31e8573 100644 --- a/include/inst.sh +++ b/include/inst.sh @@ -175,7 +175,7 @@ _inst_run() { return 1 fi - trap _inst_stop_self INT HUP TERM EXIT QUIT + trap _inst_stop_self INT HUP TERM if ! "$cmd" "${args[@]}"; then ret=1 @@ -187,7 +187,7 @@ _inst_run() { log_error "Could not destroy semaphore $__inst_sem" fi - return "$ret" + exit "$ret" } inst_start() {