Search in sources :

Example 1 with WindowsProcess

use of org.zeroturnaround.process.WindowsProcess in project aws-greengrass-nucleus by aws-greengrass.

the class WindowsPlatform method killProcessAndChildren.

@Override
public Set<Integer> killProcessAndChildren(Process process, boolean force, Set<Integer> additionalPids, UserDecorator decorator) throws IOException, InterruptedException {
    PidProcess pp = Processes.newPidProcess(process);
    ((WindowsProcess) pp).setIncludeChildren(true);
    ((WindowsProcess) pp).setGracefulDestroyEnabled(true);
    try {
        pp.destroy(force);
    } catch (InvalidExitValueException e) {
        // In other words, we rethrow the exception if the process is still alive.
        if (process.isAlive()) {
            throw e;
        }
    }
    return Collections.emptySet();
}
Also used : WindowsProcess(org.zeroturnaround.process.WindowsProcess) PidProcess(org.zeroturnaround.process.PidProcess) InvalidExitValueException(org.zeroturnaround.exec.InvalidExitValueException)

Aggregations

InvalidExitValueException (org.zeroturnaround.exec.InvalidExitValueException)1 PidProcess (org.zeroturnaround.process.PidProcess)1 WindowsProcess (org.zeroturnaround.process.WindowsProcess)1