use of org.ow2.tests.ProcessKiller in project scheduling by ow2-proactive.
the class NodesRecoveryProcessHelper method findPidAndSendSigKill.
public static void findPidAndSendSigKill(String javaProcessName) throws IOException, InterruptedException, ProcessNotFoundException {
int pidToKill;
OperatingSystem os = OperatingSystem.UNIX;
if (System.getProperty("os.name").contains("Windows")) {
os = OperatingSystem.WINDOWS;
}
switch(os) {
case WINDOWS:
pidToKill = getWindowsFirstJavaProcessPidWithName(javaProcessName);
break;
case UNIX:
pidToKill = getUnixFirstJavaProcessPidWithName(javaProcessName);
break;
default:
throw new IllegalStateException("Unsupported operating system");
}
// a process killer suitable for windows or unix operating systems
ProcessKiller processKiller = ProcessKiller.get();
processKiller.kill(pidToKill);
}
Aggregations