]> granicus.if.org Git - python/commitdiff
added TerminateProcess support to _subprocess driver
authorFredrik Lundh <fredrik@pythonware.com>
Sun, 18 Dec 2005 21:06:46 +0000 (21:06 +0000)
committerFredrik Lundh <fredrik@pythonware.com>
Sun, 18 Dec 2005 21:06:46 +0000 (21:06 +0000)
PC/_subprocess.c

index 10e1e7aa3391b32eab9347ed85b3573f9b07727c..8ed4899d8cbeac819a88013e3b923dcc9f6a7c13 100644 (file)
@@ -424,6 +424,26 @@ sp_CreateProcess(PyObject* self, PyObject* args)
                             pi.dwThreadId);
 }
 
+static PyObject *
+sp_TerminateProcess(PyObject* self, PyObject* args)
+{
+       BOOL result;
+
+       long process;
+       int exit_code;
+       if (! PyArg_ParseTuple(args, "li:TerminateProcess", &process,
+                              &exit_code))
+               return NULL;
+
+       result = TerminateProcess((HANDLE) process, exit_code);
+
+       if (! result)
+               return PyErr_SetFromWindowsErr(GetLastError());
+
+       Py_INCREF(Py_None);
+       return Py_None;
+}
+
 static PyObject *
 sp_GetExitCodeProcess(PyObject* self, PyObject* args)
 {
@@ -498,6 +518,7 @@ static PyMethodDef sp_functions[] = {
        {"DuplicateHandle",     sp_DuplicateHandle,     METH_VARARGS},
        {"CreatePipe",          sp_CreatePipe,          METH_VARARGS},
        {"CreateProcess",       sp_CreateProcess,       METH_VARARGS},
+       {"TerminateProcess",    sp_TerminateProcess,    METH_VARARGS},
        {"GetExitCodeProcess",  sp_GetExitCodeProcess,  METH_VARARGS},
        {"WaitForSingleObject", sp_WaitForSingleObject, METH_VARARGS},
        {"GetVersion",          sp_GetVersion,          METH_VARARGS},