try {
IntByReference status = new IntByReference(0);
if(kernel32().GetExitCodeProcess(ptr, status) == 0) {
throw runtime.newErrnoEPERMError("unable to call GetExitCodeProcess " + pid); // todo better error messages
} else {
if (status.intValue() == STILL_ACTIVE) {
if (kernel32().TerminateProcess(ptr, 0) == 0) {
throw runtime.newErrnoEPERMError("unable to call TerminateProcess " + pid);
}
// success
}