Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Terminate Windows processes with SIGTERM code rather than 0 #1150

Merged
merged 1 commit into from
Oct 20, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion psutil/_psutil_windows.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <wtsapi32.h>
#include <Winsvc.h>
#include <PowrProf.h>
#include <signal.h>

// Link with Iphlpapi.lib
#pragma comment(lib, "IPHLPAPI.lib")
Expand Down Expand Up @@ -349,7 +350,7 @@ psutil_proc_kill(PyObject *self, PyObject *args) {
}

// kill the process
if (! TerminateProcess(hProcess, 0)) {
if (! TerminateProcess(hProcess, SIGTERM)) {
err = GetLastError();
// See: https://github.com/giampaolo/psutil/issues/1099
if (err != ERROR_ACCESS_DENIED) {
Expand Down
10 changes: 5 additions & 5 deletions psutil/tests/test_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ def test_wait(self):
if POSIX:
self.assertEqual(code, -signal.SIGKILL)
else:
self.assertEqual(code, 0)
self.assertEqual(code, signal.SIGTERM)
self.assertFalse(p.is_running())

sproc = get_test_subprocess()
Expand All @@ -161,7 +161,7 @@ def test_wait(self):
if POSIX:
self.assertEqual(code, -signal.SIGTERM)
else:
self.assertEqual(code, 0)
self.assertEqual(code, signal.SIGTERM)
self.assertFalse(p.is_running())

# check sys.exit() code
Expand Down Expand Up @@ -207,8 +207,8 @@ def test_wait_non_children(self):
# to get None.
self.assertEqual(ret2, None)
else:
self.assertEqual(ret1, 0)
self.assertEqual(ret1, 0)
self.assertEqual(ret1, signal.SIGTERM)
self.assertEqual(ret1, signal.SIGTERM)

def test_wait_timeout_0(self):
sproc = get_test_subprocess()
Expand All @@ -227,7 +227,7 @@ def test_wait_timeout_0(self):
if POSIX:
self.assertEqual(code, -signal.SIGKILL)
else:
self.assertEqual(code, 0)
self.assertEqual(code, signal.SIGTERM)
self.assertFalse(p.is_running())

def test_cpu_percent(self):
Expand Down