RFR: 8291067: macOS should use O_CLOEXEC instead of FD_CLOEXEC

Gerard Ziemski gziemski at openjdk.org
Mon Aug 1 16:18:51 UTC 2022


On Sun, 31 Jul 2022 21:55:03 GMT, David Holmes <dholmes at openjdk.org> wrote:

>> Sorry but copying a comment from os_linux to os_bsd really doesn't make sense. We've been cleaning up these "mis-ports" ever since the macOS port was done, so please don't add new occurrences.
>
> I see now it is just not comments but also the code. Again sorry but if the Linux workarounds are for Linux then they don't belong in the BSD code. That just confuses anyone who looks at this code later. If there were eventually an os_posix shared version of this then it wouldn't include Linux specific workarounds.

This is not a **workaround** but an improvement to the robustness of the code, that applies equally to both Linux and macOS, by taking an advantage of what once was a new feature, but now is just a more reliable mechanism for making sure that the forked/child process does not get access to unintended "leaked" file descriptor from the parent. The original comment came from Linux, but we can change it, to apply equally to both Linux/macOS.

I will refactor this common POSIX code, though they are not 100% exactly the same - Linux uses `open64()`, while macOS uses `open()`.

-------------

PR: https://git.openjdk.org/jdk/pull/9663


More information about the hotspot-runtime-dev mailing list