--- old/./src/solaris/classes/java/lang/UNIXProcess.java.linux 2012-09-07 14:37:48.951436575 -0400 +++ new/./src/solaris/classes/java/lang/UNIXProcess.java.linux 2012-09-07 14:37:48.799436579 -0400 @@ -34,6 +34,11 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; +import java.nio.charset.Charset; +import java.nio.file.Files; +import java.nio.file.LinkOption; +import java.nio.file.Path; +import java.nio.file.Paths; import java.util.Arrays; import java.util.concurrent.Executors; import java.util.concurrent.Executor; @@ -270,6 +275,33 @@ return !hasExited; } + @Override + public int getPid() { + if (!isAlive()) { + return -1; + } else { + return pid; + } + } + + @Override + public String getProcessName(int pid) { + // look at /proc//comm + if (pid < 0) { + throw new IllegalArgumentException( "pid == " + pid ); + } + Path p = Paths.get( "/proc/" + pid + "/comm" ); + if (!Files.exists(p, LinkOption.NOFOLLOW_LINKS )) { + return null; + } + + try { + return Files.readAllLines( p, Charset.defaultCharset() ).get(0); + } catch (IOException ioex) { + throw new RuntimeException( ioex ); + } + } + /* This routine initializes JNI field offsets for the class */ private static native void initIDs();