クラス ProcessTerminator
- java.lang.Object
-
- com.kazurayam.subprocessj.ProcessTerminator
-
public class ProcessTerminator extends java.lang.Object
killProcessListeningPort(int portNumber) identifies the running process that is listening the IP port #portNumber, get the Process ID, then kill the process. I want this class to run on Java 8. Therefore I can not rely on the `long pid()` method of `java.lang.Process` which was added at Java 9. So I will use `lsof -i:portNumber -P` command on Mac on Windows? TODO later
-
-
ネストされたクラスの概要
ネストされたクラス 修飾子とタイプ クラス 説明 static class
ProcessTerminator.ProcessTerminationResult
A Data Transfer Object that contains the return code, STDOUT of `lsof -i:port -P` command that reveals how ProcessKiller worked.
-
コンストラクタの概要
コンストラクタ コンストラクタ 説明 ProcessTerminator()
-
メソッドの概要
すべてのメソッド staticメソッド concreteメソッド 修飾子とタイプ メソッド 説明 static ProcessTerminator.ProcessTerminationResult
killProcessByPid(ProcessFinder.ProcessFindingResult pfr)
static ProcessTerminator.ProcessTerminationResult
killProcessOnPort(int portNumber)
static void
main(java.lang.String[] args)
-
-
-
メソッドの詳細
-
killProcessOnPort
public static ProcessTerminator.ProcessTerminationResult killProcessOnPort(int portNumber) throws java.io.IOException, java.lang.InterruptedException
- パラメータ:
portNumber
- the IP port number on which the Process is hanging on; you want to kill that process.- 戻り値:
- the ID of the process (>0) which is listening to the IP portNumber and therefore killed; returns -1 if the process was not found.
- 例外:
java.io.IOException
- if failed to kill a OS processjava.lang.InterruptedException
- if the process was interrupted
-
killProcessByPid
public static ProcessTerminator.ProcessTerminationResult killProcessByPid(ProcessFinder.ProcessFindingResult pfr) throws java.io.IOException, java.lang.InterruptedException
- 例外:
java.io.IOException
java.lang.InterruptedException
-
main
public static void main(java.lang.String[] args) throws java.io.IOException, java.lang.InterruptedException
- 例外:
java.io.IOException
java.lang.InterruptedException
-
-