/** * <p>Get the process id from the operating system.</p> * * Unfortunately, there is no simple method to get the process id in Java. * The approach we take here is to use the shell method (see * {TracerId#getOsPidFromShellPpid}) unless we are on Windows, where the * shell is not available. On Windows, we use * {TracerId#getOsPidFromManagementFactory}, which depends on some * undocumented features of the JVM, but which doesn't require a shell. */ static long getOsPid() { if ((System.getProperty("os.name", "generic").toLowerCase(Locale.ENGLISH)). contains("windows")) { return getOsPidFromManagementFactory(); } else { return getOsPidFromShellPpid(); } }
/** * Get the process id from the operating system.<p/> * * Unfortunately, there is no simple method to get the process id in Java. * The approach we take here is to use the shell method (see * {TracerId#getOsPidFromShellPpid}) unless we are on Windows, where the * shell is not available. On Windows, we use * {TracerId#getOsPidFromManagementFactory}, which depends on some * undocumented features of the JVM, but which doesn't require a shell. */ static long getOsPid() { if ((System.getProperty("os.name", "generic").toLowerCase(Locale.ENGLISH)). contains("windows")) { return getOsPidFromManagementFactory(); } else { return getOsPidFromShellPpid(); } }
/** * <p>Get the process id from the operating system.</p> * * Unfortunately, there is no simple method to get the process id in Java. * The approach we take here is to use the shell method (see * {TracerId#getOsPidFromShellPpid}) unless we are on Windows, where the * shell is not available. On Windows, we use * {TracerId#getOsPidFromManagementFactory}, which depends on some * undocumented features of the JVM, but which doesn't require a shell. */ static long getOsPid() { if ((System.getProperty("os.name", "generic").toLowerCase(Locale.ENGLISH)). contains("windows")) { return getOsPidFromManagementFactory(); } else { return getOsPidFromShellPpid(); } }