Use Java 11 ProcessHandle to get pid of the current process
Change-Id: I790f218601c1d5e1b39c4101e3b2708e76b9d782
This commit is contained in:
parent
aa13d1daf5
commit
2a2a208fa1
|
@ -1713,17 +1713,7 @@ private String getProcDesc() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private long getPID() {
|
private long getPID() {
|
||||||
String processName = java.lang.management.ManagementFactory
|
return ProcessHandle.current().pid();
|
||||||
.getRuntimeMXBean().getName();
|
|
||||||
if (processName != null && processName.length() > 0) {
|
|
||||||
try {
|
|
||||||
return Long.parseLong(processName.split("@")[0]); //$NON-NLS-1$
|
|
||||||
} catch (Exception e) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getHostName() {
|
private String getHostName() {
|
||||||
|
|
Loading…
Reference in New Issue