void ProcessImpl::killImpl(PIDImpl pid) { HANDLE hProc = OpenProcess(PROCESS_TERMINATE, FALSE, pid); if (hProc) { if (TerminateProcess(hProc, 0) == 0) { CloseHandle(hProc); throw SystemException("cannot kill process"); } CloseHandle(hProc); } else { switch (GetLastError()) { case ERROR_ACCESS_DENIED: throw NoPermissionException("cannot kill process"); case ERROR_NOT_FOUND: throw NotFoundException("cannot kill process"); default: throw SystemException("cannot kill process"); } } }
void ProcessImpl::requestTerminationImpl(PIDImpl pid) { if (kill(pid, SIGINT) != 0) { switch (errno) { case ESRCH: throw NotFoundException("cannot terminate process"); case EPERM: throw NoPermissionException("cannot terminate process"); default: throw SystemException("cannot terminate process"); } } }
void ProcessImpl::killImpl(PIDImpl pid) { if (kill(pid, SIGKILL) != 0) { switch (errno) { case ESRCH: throw NotFoundException("cannot kill process"); case EPERM: throw NoPermissionException("cannot kill process"); default: throw SystemException("cannot kill process"); } } }