]> git.corax.cc Git - toolbox/commitdiff
include/inst: Allow terminated instances to be cleaned up properly
authorMatthias Kruk <m@m10k.eu>
Sat, 26 Nov 2022 03:41:25 +0000 (12:41 +0900)
committerMatthias Kruk <m@m10k.eu>
Sat, 26 Nov 2022 03:41:25 +0000 (12:41 +0900)
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

index c96e4899792c39d299dd5852a94afd4db1ccb990..31e8573e4a3d2ba8b051fbf41de49992f4c0f266 100644 (file)
@@ -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() {