./src/share/classes/java/lang/Process.java
Print this page
*** 24,33 ****
--- 24,36 ----
*/
package java.lang;
import java.io.*;
+ import java.util.ArrayList;
+ import java.util.Collections;
+ import java.util.List;
import java.util.concurrent.TimeUnit;
/**
* The {@link ProcessBuilder#start()} and
* {@link Runtime#exec(String[],String[],File) Runtime.exec}
*** 73,82 ****
--- 76,86 ----
* to create a {@code Process}.
*
* @since JDK1.0
*/
public abstract class Process {
+
/**
* Returns the output stream connected to the normal input of the
* subprocess. Output to the stream is piped into the standard
* input of the process represented by this {@code Process} object.
*
*** 260,265 ****
--- 264,309 ----
return false;
} catch(IllegalThreadStateException e) {
return true;
}
}
+
+ /**
+ * Returns the process id of the subprocess
+ *
+ * @return the process id or -1 if the process is not alive
+ * @since 1.8
+ */
+ public abstract int getPid();
+
+ /**
+ * Returns the process id of the current process.
+ *
+ * @return the process id of the current process.
+ * @since 1.8
+ *
+ **/
+ public static native int getCurrentPid();
+
+ public abstract String getProcessName(int pid);
+
+ /**
+ * @return the process name of the current process.
+ * @since 1.8
+ */
+ public String getCurrentProcessName() {
+ return getProcessName( getCurrentPid() );
+ }
+
+ /**
+ * @return the process name of this process or null if no longer live
+ * @since 1.8
+ */
+ public String getProcessName() {
+ int pid = getPid();
+ if (pid >=0) {
+ return getProcessName( getPid() );
+ } else {
+ return null;
+ }
+ }
}