I want to be able to kill a ping started from my java program, but I need to get the pid to do so. I also did some research and I found out that I can use SendSignal.exe to send Ctl+C, but I need the pid of the process that I have just started. Is there a way in Java to get the pid?
Process p = null;
InputStream processOutput;
BufferedReader reader = null;
String line = " ";
p = Runtime.getRuntime().exec("cmd /c " + command);
processOutput = p.getInputStream();
reader = new BufferedReader(new InputStreamReader(processOutput));
// Read the input
while((line = reader.readLine()) != null){
output += line + "\n";
System.out.println(line);
}