Comment by 112233

Comment by 112233 2 days ago

0 replies

> you can fsync and close it fine afterwards

No you cannot. Once you pass descriptor to another process, that process can pass it to yet another process, fork and detach, send it via SCM_RIGHTS, give "/proc/PID/fd/N" path to something etc.

Never assume descriptor cleanup will happen, unless you have complete control over everything.