The FD_CLOEXEC flag is used to mark file descriptors that should be used when an exec function is called. During fork, this flag is initiated by the child process. The kernel ensures that these flags are correctly set in the child's file descriptor tables.