Is this actually safe to do? Earlier you used the presence of O_CLOEXEC as a hint that the feature may be present and falled back. Here you're assuming that it exists. So for example, on a FreeBSD system that doesn't support O_CLOEXEC, you'll do the wrong thing. I'm less concerned with bringing a binary built for a newer system to an older one, as that is fraught with perils, but if that's something you care about based on the other work that you have trying to fall back, then this won't work.