mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2026-10-29 07:50:04 -05:00
Found by aggressive review of 83abb1c4f: 1. fd leak on os.fdopen failure — os.open returns a raw fd; if os.fdopen() raises after, the fd is orphaned. Wrap in try/except and close on failure. Built-in open() doesn't have this issue because it manages the fd internally. 2. Silent regression of close-on-exec — Python's built-in open() sets fds non-inheritable by default since PEP 446 (3.4+). os.open() does not. Replacing the default open path therefore made the log fd inheritable across fork/exec — mostly harmless in pgAdmin's subprocess paths (they default close_fds=True) but still a silent behavioral diff. OR in O_CLOEXEC to match. Also adds web/pgadmin/utils/tests/test_enhanced_log_rotation.py covering: new file mode, rotated archive + new active file mode, pre-existing file mode unchanged, and fd non-inheritable. Skipped on Windows where POSIX mode bits and PEP 446 semantics differ. Verified all 4 cases pass via web/regression/runtests.py --pkg utils.