From 78573c48aad68170a197bf7a81af51309fc5c06e Mon Sep 17 00:00:00 2001 From: Matthias Kruk Date: Sat, 26 Nov 2022 12:41:25 +0900 Subject: [PATCH] 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. --- include/inst.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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() { -- 2.47.3