mirror of
https://gitlab.com/etherlab.org/ethercat.git
synced 2026-02-07 20:31:50 +08:00
This flag specifies that the file descriptor should be closed when an exec function is invoked. When a file descriptor is allocated (as with open or dup), O_CLOEXEC bit is initially cleared on the new file descriptor, meaning that descriptor will survive into the new program after exec. Setting O_CLOEXEC avoid this survival of the desciptor in the new program. And setting it at open() time is the only race-free way to avoid accidentally leaking the fd via other threads that concurrently do fork()+exec() (or similar, e.g. posix_spawn).