Class ProcessUtils
java.lang.Object
com.sun.enterprise.universal.process.ProcessUtils
Includes a somewhat kludgy way to get the pid for "me". Another casualty of
the JDK catering to the LEAST common denominator. Some obscure OS might not
have a pid! The name returned from the JMX method is like so: 12345
- Author:
- bnevins
-
Method Summary
Modifier and TypeMethodDescriptionstatic FileLook for name in the Path.static intgetPid()Try and find the Process ID of "our" process.static BooleanisProcessRunning(int aPid) If we can determine it -- find out if the process that owns the given process id is running.static Stringkill(int pid) Kill the process with the given Process ID.static StringKill the JVM with the given main classname.static void
-
Method Details
-
main
-
getExe
Look for name in the Path. If it is found and if it is executable then return a File object pointing to it. Otherwise return nu- Parameters:
name- the name of the file with no path- Returns:
- the File object or null
-
getPid
public static int getPid()Try and find the Process ID of "our" process.- Returns:
- the process id or -1 if not known
-
kill
Kill the process with the given Process ID.- Parameters:
pid-- Returns:
- a String if the process was not killed for any reason including if it does not exist. Return null if it was killed.
-
killJvm
Kill the JVM with the given main classname. The classname can be fully-qualified or just the classname (i.e. without the package name prepended).- Parameters:
pid-- Returns:
- a String if the process was not killed for any reason including if it does not exist. Return null if it was killed.
-
isProcessRunning
If we can determine it -- find out if the process that owns the given process id is running.- Parameters:
aPid-- Returns:
- true if it's running, false if not and null if we don't know. I.e the return value is a true tri-state Boolean.
-