~dxld/oida

79bbea03480a40e0c93b346c9f131a6f561c0d5b — Daniel Gröber a month ago 2c8d4a3
Inhibit cleanup by unregistering traps
1 files changed, 8 insertions(+), 14 deletions(-)

M lib/oida-cleanup.sh
M lib/oida-cleanup.sh => lib/oida-cleanup.sh +8 -14
@@ 201,6 201,9 @@ _cleanup_do_all () {

# Close all cleanup namespace reference FDs
_cleanup_close_fds () {
	exec {CLEANUP_CURRENT_NS}>&-
	exec {CLEANUP_CURRENT_ROOT}>&-
	unset CLEANUP_CURRENT_NS CLEANUP_CURRENT_ROOT
	for fd in "${CLEANUP_ns[@]}" "${CLEANUP_root[@]}"
	do
		exec {fd}>&-


@@ 247,31 250,22 @@ cleanup_do () {
		return 0
	fi

	cleanup_inhibit_push ALL

	cleanup_unregister_traps
	local rv=0
	_cleanup_do_all || rv=$?

	_cleanup_close_fds

	CLEANUP=()
	CLEANUP_idx=()
	CLEANUP_len=()
	CLEANUP_ns=()
	CLEANUP_root=()
	CLEANUP_cwd=()

	cleanup_inhibit_pop ALL
	_cleanup_init_vars

	if [ "$sig" != ALL ]; then
		trap - "$sig"
		kill -"$sig" $$
		kill -"$sig" $$ # TODO: check and document kill -EXIT
	fi

	# If we don't end up killing ourselves above exit if cleanup failed
	if [ $rv -ne 0 ]; then
		exit "$rv"
	fi

	cleanup_register_traps
}

cleanup_init