@@ -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+
427447static PyObject *
428448sp_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