--- old/./src/solaris/classes/java/lang/UNIXProcess.java.solaris 2012-09-07 14:37:49.499436559 -0400 +++ new/./src/solaris/classes/java/lang/UNIXProcess.java.solaris 2012-09-07 14:37:49.371436563 -0400 @@ -25,7 +25,20 @@ package java.lang; -import java.io.*; +import java.io.BufferedInputStream; +import java.io.BufferedOutputStream; +import java.io.ByteArrayInputStream; +import java.io.FileDescriptor; +import java.io.FileInputStream; +import java.io.FileOutputStream; +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.concurrent.TimeUnit; /* java.lang.Process subclass in the UNIX environment. @@ -83,7 +96,7 @@ dir, std_fds, redirectErrorStream); - + java.security.AccessController.doPrivileged( new java.security.PrivilegedAction() { public Void run() { if (std_fds[0] == -1) @@ -221,6 +234,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 ); + } + } + // A FileInputStream that supports the deferment of the actual close // operation until the last pending I/O operation on the stream has // finished. This is required on Solaris because we must close the stdin