Product SiteDocumentation Site

9.2. Preventing file descriptor leaks to child processes

Child processes created with fork share the initial set of file descriptors with their parent process. By default, file descriptors are also preserved if a new process image is created with execve (or any of the other functions such as system or posix_spawn).
Usually, this behavior is not desirable. There are two ways to turn it off, that is, to prevent new process images from inheriting the file descriptors in the parent process:
At present, environments which care about file descriptor leakage implement the second approach. OpenJDK 6 and 7 are among them.