Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e515293

Browse files
author
Fredrik Lundh
committed
added TerminateProcess support to _subprocess driver
1 parent 118be0c commit e515293

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

PC/_subprocess.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,26 @@ sp_CreateProcess(PyObject* self, PyObject* args)
424424
pi.dwThreadId);
425425
}
426426

427+
static PyObject *
428+
sp_TerminateProcess(PyObject* self, PyObject* args)
429+
{
430+
BOOL result;
431+
432+
long process;
433+
int exit_code;
434+
if (! PyArg_ParseTuple(args, "li:TerminateProcess", &process,
435+
&exit_code))
436+
return NULL;
437+
438+
result = TerminateProcess((HANDLE) process, exit_code);
439+
440+
if (! result)
441+
return PyErr_SetFromWindowsErr(GetLastError());
442+
443+
Py_INCREF(Py_None);
444+
return Py_None;
445+
}
446+
427447
static PyObject *
428448
sp_GetExitCodeProcess(PyObject* self, PyObject* args)
429449
{
@@ -498,6 +518,7 @@ static PyMethodDef sp_functions[] = {
498518
{"DuplicateHandle", sp_DuplicateHandle, METH_VARARGS},
499519
{"CreatePipe", sp_CreatePipe, METH_VARARGS},
500520
{"CreateProcess", sp_CreateProcess, METH_VARARGS},
521+
{"TerminateProcess", sp_TerminateProcess, METH_VARARGS},
501522
{"GetExitCodeProcess", sp_GetExitCodeProcess, METH_VARARGS},
502523
{"WaitForSingleObject", sp_WaitForSingleObject, METH_VARARGS},
503524
{"GetVersion", sp_GetVersion, METH_VARARGS},

0 commit comments

Comments
 (0)