Prevent file descriptors inheritance during Linux fork
问题 How do you prevent a file descriptor from being copy-inherited across fork() syscalls (without closing it, of course) ? I am looking for a way to mark a single file descriptor as NOT to be (copy-)inherited by children at fork(), something like a FD_CLOEXEC-like hack but for forks (so a FD_DONTINHERIT feature if you like). Anybody did this? Or looked into this and has a hint for me to start with? Thank you UPDATE: I could use libc's __register_atfork __register_atfork(NULL, NULL, fdcleaner,