When should I use O_CLOEXEC when I open file in Linux? When should I use O_CLOEXEC when I open file in Linux? linux linux

When should I use O_CLOEXEC when I open file in Linux?


Yes, unless you need the program you exec to have access to that file descriptor. You can also close the file descriptor manually in the child process before calling exec, but that's more error prone.