JDK-8271858 : Handle to jimage file inherited into child processes (posix)
  • Type: Bug
  • Component: tools
  • Sub-Component: jlink
  • Affected Version: 11,18
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • Submitted: 2021-08-04
  • Updated: 2021-08-04
Related Reports
Relates :  
Description
We should not leak the handle to the jimage file (lib/modules) to childs.

JDK-8194734 did solve this for windows. We should use FD_CLOEXEC on Posix as well.

Note that this only poses a problem when a child process is spawned off not via `Runtime.exec` but via another route since the spawnhelper closes all file descriptors.


Comments
@alan True. The background for this fix is that I investigate how feasible would be a gtest which tests that no file handles are inherited to childs. This is still in investigation phase, but I wanted to get obvious small fixes out of the way first.
04-08-2021

No objection to using FD_CLOEXEC but if something is using fork directly then it will likely have implications for many areas of the JDK libraries.
04-08-2021