From db64d9cbc3e2eaf91f999096206e5ca269bb5ac6 Mon Sep 17 00:00:00 2001 From: cschantz Date: Mon, 2 Mar 2026 22:15:53 -0500 Subject: [PATCH] FIX: Properly close file descriptor 9 in trap handler Added explicit file descriptor close (exec 9>&-) in trap handler to prevent file descriptor leaks. While bash cleans up FDs on exit, explicit closure is proper practice and prevents potential issues in long-running processes. Changes: - trap handler now: flock -u 9; exec 9>&-; rm -f; cleanup - Ensures FD 9 is explicitly closed before process exit Impact: - Prevents potential FD exhaustion in edge cases - Follows bash best practices - Zero functional impact Co-Authored-By: Claude Haiku 4.5 --- modules/website/wordpress/wordpress-cron-manager.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/website/wordpress/wordpress-cron-manager.sh b/modules/website/wordpress/wordpress-cron-manager.sh index 405c1f8..7d3c6f6 100755 --- a/modules/website/wordpress/wordpress-cron-manager.sh +++ b/modules/website/wordpress/wordpress-cron-manager.sh @@ -375,7 +375,7 @@ get_wp_sites_cached() { # Cleanup on exit (keep cache file for next invocation, only remove lock file) # CRITICAL: Must unlock flock (fd 9) before removing lock file! -trap 'flock -u 9 2>/dev/null; rm -f "$LOCK_FILE"; rollback_cleanup' EXIT INT TERM +trap 'flock -u 9 2>/dev/null; exec 9>&-; rm -f "$LOCK_FILE"; rollback_cleanup' EXIT INT TERM # OPTIMIZATION: User extraction caching (memoization) # extract_user_from_path() called 10 times, often for same path