Skip to content

Instantly share code, notes, and snippets.

@vvkirillov
Created October 21, 2015 09:06
Show Gist options
  • Save vvkirillov/4b1e598312180586d6f7 to your computer and use it in GitHub Desktop.
Save vvkirillov/4b1e598312180586d6f7 to your computer and use it in GitHub Desktop.
Get process id in UNIX from Java
public int getPid(Process process) throws Exception{
if(process.getClass().getName().equals("java.lang.UNIXProcess")) {
Field f = process.getClass().getDeclaredField("pid");
f.setAccessible(true);
return f.getInt(process);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment