Issue #16860: In tempfile, use O_CLOEXEC when available to set the
close-on-exec flag atomically.