File tree 1 file changed +6
-14
lines changed
1 file changed +6
-14
lines changed Original file line number Diff line number Diff line change @@ -244,7 +244,6 @@ static PyObject *
244
244
psutil_proc_kill (PyObject * self , PyObject * args ) {
245
245
HANDLE hProcess ;
246
246
long pid ;
247
- DWORD exitCode ;
248
247
249
248
if (! PyArg_ParseTuple (args , "l" , & pid ))
250
249
return NULL ;
@@ -266,19 +265,12 @@ psutil_proc_kill(PyObject *self, PyObject *args) {
266
265
}
267
266
268
267
if (! TerminateProcess (hProcess , SIGTERM )) {
269
- if (GetLastError () == ERROR_ACCESS_DENIED ) {
270
- // ERROR_ACCESS_DENIED (winerror 5) may happen if the
271
- // process already died. See:
272
- // https://github.com/giampaolo/psutil/issues/1099
273
- // https://github.com/giampaolo/psutil/issues/1595
274
- if (GetExitCodeProcess (hProcess , & exitCode ) == 0 ) {
275
- PyErr_SetFromOSErrnoWithSyscall ("GetExitCodeProcess" );
276
- goto error ;
277
- }
278
- if (exitCode == STILL_ACTIVE ) {
279
- PyErr_SetFromOSErrnoWithSyscall ("TerminateProcess" );
280
- goto error ;
281
- }
268
+ // ERROR_ACCESS_DENIED may happen if the process already died. See:
269
+ // https://github.com/giampaolo/psutil/issues/1099
270
+ // https://github.com/giampaolo/psutil/issues/1595
271
+ if ((GetLastError () == ERROR_ACCESS_DENIED ) && \
272
+ (psutil_pid_is_running (pid ) == 0 ))
273
+ {
282
274
CloseHandle (hProcess );
283
275
Py_RETURN_NONE ;
284
276
}
You can’t perform that action at this time.
0 commit comments