mirror of https://github.com/alibaba/arthas.git
add tutorials link
parent
813ab9304e
commit
c390d5571b
@ -0,0 +1,30 @@
|
||||
package com.taobao.arthas.common;
|
||||
|
||||
import java.lang.management.ManagementFactory;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author hengyunabc 2019-02-16
|
||||
*
|
||||
*/
|
||||
public class PidUtils {
|
||||
private static String PID = "-1";
|
||||
|
||||
static {
|
||||
// https://stackoverflow.com/a/7690178
|
||||
String jvmName = ManagementFactory.getRuntimeMXBean().getName();
|
||||
int index = jvmName.indexOf('@');
|
||||
|
||||
if (index > 0) {
|
||||
try {
|
||||
PID = Long.toString(Long.parseLong(jvmName.substring(0, index)));
|
||||
} catch (Throwable e) {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static String currentPid() {
|
||||
return PID;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue