This can help: https://man7.org/linux/man-pages/man2/close_range.2.html
close_range(3, ~0U, CLOSE_RANGE_UNSHARE);
execve(....);
...but it's not very portable yet.