From b2414b83d3d728ec34ea0e35bfb21517ee231401 Mon Sep 17 00:00:00 2001 From: Giampaolo Rodola Date: Fri, 22 Nov 2019 14:19:14 +0800 Subject: [PATCH] revert #1595 --- HISTORY.rst | 1 - psutil/_psutil_windows.c | 13 +------------ 2 files changed, 1 insertion(+), 13 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index 1d3b34a24..5cef298c0 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -9,7 +9,6 @@ XXXX-XX-XX - 1179_: [Linux] Process cmdline() now takes into account misbehaving processes renaming the command line and using inappropriate chars to separate args. -- 1595_: [Windows] Process.kill() may not throw AccessDenied. - 1616_: use of Py_DECREF instead of Py_CLEAR will result in double free and segfault (CVE). (patch by Riccardo Schirone) - 1619_: [OpenBSD] compilation fails due to C syntax error. (patch by Nathan diff --git a/psutil/_psutil_windows.c b/psutil/_psutil_windows.c index be0b2337f..959919342 100644 --- a/psutil/_psutil_windows.c +++ b/psutil/_psutil_windows.c @@ -267,14 +267,7 @@ psutil_proc_kill(PyObject *self, PyObject *args) { if (! TerminateProcess(hProcess, SIGTERM)) { // ERROR_ACCESS_DENIED may happen if the process already died. See: // https://github.com/giampaolo/psutil/issues/1099 - // https://github.com/giampaolo/psutil/issues/1595 - if ((GetLastError() == ERROR_ACCESS_DENIED) && \ - (psutil_pid_is_running(pid) == 0)) - { - CloseHandle(hProcess); - Py_RETURN_NONE; - } - else { + if (GetLastError() != ERROR_ACCESS_DENIED) { PyErr_SetFromOSErrnoWithSyscall("TerminateProcess"); goto error; } @@ -282,10 +275,6 @@ psutil_proc_kill(PyObject *self, PyObject *args) { CloseHandle(hProcess); Py_RETURN_NONE; - -error: - CloseHandle(hProcess); - return NULL; }