Search in sources :

Example 1 with ProcessKiller

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);
}
Also used : OperatingSystem(org.ow2.proactive.resourcemanager.utils.OperatingSystem) ProcessKiller(org.ow2.tests.ProcessKiller)

Aggregations

OperatingSystem (org.ow2.proactive.resourcemanager.utils.OperatingSystem)1 ProcessKiller (org.ow2.tests.ProcessKiller)1