From 19173754ec69926240e2a691e01f7529dca2384d Mon Sep 17 00:00:00 2001 From: Andrea Mazzoleni Date: Mon, 10 Aug 2026 12:52:37 +0200 Subject: [PATCH] Comment explaining why CLOSE_RANGE_CLOEXEC is safe for fexecve binaries in os_spawn --- os/unix.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/os/unix.c b/os/unix.c index 52a2371c..af372b2a 100644 --- a/os/unix.c +++ b/os/unix.c @@ -1282,6 +1282,8 @@ pid_t os_spawn(char** argv, int* stdout_read_fd, int* stderr_read_fd, const char * * fallback: if it fails, we assume to be still safe, as all fds and * sockets should be already created with CLOEXEC. + * + * For binaries fd can be set as CLOEXEC because fexecve loads the ELF image into memory before closing descriptors. */ close_range(3, ~0U, CLOSE_RANGE_CLOEXEC); #endif