This is an automated email from the ASF dual-hosted git repository. ppalaga pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/maven-mvnd.git
commit 2ab4cd80831e9de88d4ef752787aecdc4d2b815f Author: Jesse Glick <jgl...@apache.org> AuthorDate: Tue Mar 22 14:41:11 2022 -0400 Only check `/proc/self` if apparently on Linux (always fall back to VM name) --- .../org/mvndaemon/mvnd/common/DaemonRegistry.java | 30 ++++++++++++---------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/common/src/main/java/org/mvndaemon/mvnd/common/DaemonRegistry.java b/common/src/main/java/org/mvndaemon/mvnd/common/DaemonRegistry.java index 7fcf21c..5d3d7a8 100644 --- a/common/src/main/java/org/mvndaemon/mvnd/common/DaemonRegistry.java +++ b/common/src/main/java/org/mvndaemon/mvnd/common/DaemonRegistry.java @@ -271,23 +271,25 @@ public class DaemonRegistry implements AutoCloseable { private static final int PROCESS_ID = getProcessId0(); private static int getProcessId0() { - try { - final Path self = Paths.get("/proc/self"); - if (Files.exists(self)) { - String pid = self.toRealPath().getFileName().toString(); - if (pid.equals("self")) { - LOGGER.debug("/proc/self symlink could not be followed"); - } else { - LOGGER.debug("loading own PID from /proc/self link: {}", pid); - try { - return Integer.parseInt(pid); - } catch (NumberFormatException x) { - LOGGER.warn("Unable to determine PID from malformed /proc/self link `" + pid + "`"); + if (Os.current() == Os.LINUX) { + try { + final Path self = Paths.get("/proc/self"); + if (Files.exists(self)) { + String pid = self.toRealPath().getFileName().toString(); + if (pid.equals("self")) { + LOGGER.debug("/proc/self symlink could not be followed"); + } else { + LOGGER.debug("loading own PID from /proc/self link: {}", pid); + try { + return Integer.parseInt(pid); + } catch (NumberFormatException x) { + LOGGER.warn("Unable to determine PID from malformed /proc/self link `" + pid + "`"); + } } } + } catch (IOException ignored) { + LOGGER.debug("could not load /proc/self", ignored); } - } catch (IOException ignored) { - LOGGER.debug("could not load /proc/self", ignored); } String vmname = ManagementFactory.getRuntimeMXBean().getName(); String pid = vmname.split("@", 0)[0];