You should officially check the return from fcntl(log_fd, F_GETFD).  If it's -1, you're doing a F_SETFD with all bits set; it's probably going to fail (given that F_GETFD did) but it's still not a good thing to do !  Fortunately, it probably doesn't matter (for now), as FD_CLOEXEC is the only defined flag, so setting all flags is not a problem.  However, if someone adds more flags in future (or AIX or HP-UX has some weird flags I don't know about that POSIX hasn't yet standardised), this might be Bad.

Better idea (I just read some man pages): pass O_CLOEXEC to open() and skip these fcntl()s entirely !  But you'll have to check whether that's portable.