Skip to content

Commit

Permalink
Remove UnixCommandUtil.getPID
Browse files Browse the repository at this point in the history
This is no longer required.
Use Process.pid() instead (available since Java 9).
  • Loading branch information
hannesbraun committed Aug 21, 2023
1 parent 028a77e commit e72bf60
Showing 1 changed file with 0 additions and 23 deletions.
23 changes: 0 additions & 23 deletions src/main/java/hso/autonomy/util/misc/UnixCommandUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,29 +18,6 @@
*/
public class UnixCommandUtil
{
/**
* Retrieves the pid of a unix process. (Possibly in Java 1.8 this will be
* added to the API of process??).
* @param process the process object to get the pid from
* @return the pid, -1 if not able to get it
* @throws NoSuchFieldException
* @throws SecurityException
* @throws IllegalArgumentException
* @throws IllegalAccessException
*/
public static int getPID(Process process)
throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException
{
if (process.getClass().getName().equals("java.lang.UNIXProcess")) {
/* get the PID on unix/linux systems */
Field f = process.getClass().getDeclaredField("pid");
f.setAccessible(true);
return f.getInt(process);
} else {
return -1;
}
}

/**
* Checks if the process with pid passed contains the passed name when run
* with ps. If so it is killed.
Expand Down

0 comments on commit e72bf60

Please sign in to comment.