RFR: 8314491: Linux: jexec launched via PATH fails to find java [v2]
Vladimir Petko
vpetko at openjdk.org
Mon Aug 21 06:26:52 UTC 2023
On Mon, 21 Aug 2023 04:38:56 GMT, David Holmes <dholmes at openjdk.org> wrote:
> I get the sense from the comment in jexec.c that it is only intended to be launched via a full path, so having it in the $PATH seems like a usage error to me.
Unfortunately this executable is linked in /usr/bin and is assumed to work perfectly when run as just `jexec` .
> That said this change seems relatively harmless, though I confess I do not understand how `/proc/self/exe` works and under what conditions reading it returns the actual binary path rather than "/proc/self/exe". ??
The '/proc/' filesystem contains a 'self' entry for the current process and 'exe' entry is expected to contain the symbolic link to the actual binary[1] . `realpath` call in getJavaPath() function translates the symbolic link into the binary path.
I do not have much expertise in the kernel development, but as far as I know the value of `/proc/self/exe` it is being set in Memory Descriptor structure whenever a process is created from a file[2].
Reading the symlink may return ENOENT (broken symlink) if there was no file[3].
[1] https://docs.kernel.org/filesystems/proc.html
[2] https://github.com/torvalds/linux/blob/f7757129e3dea336c407551c98f50057c22bb266/fs/exec.c#L1282
[3] https://github.com/torvalds/linux/blob/f7757129e3dea336c407551c98f50057c22bb266/fs/proc/base.c#L1730
-------------
PR Comment: https://git.openjdk.org/jdk/pull/15343#issuecomment-1685716770
More information about the core-libs-dev
mailing list