[Python-Dev] [Python-checkins] cpython: Issue #17931: Resolve confusion on Windows between pids and process handles. (original) (raw)
Brett Cannon brett at python.org
Fri Jun 7 17:16:05 CEST 2013
- Previous message: [Python-Dev] ssl improvements and testing question
- Next message: [Python-Dev] [Python-checkins] cpython: Issue #17931: Resolve confusion on Windows between pids and process handles.
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
I think this CL introduced a memory leak. The daily leak report went from 0 to not 0 between June 4 and June 5 and this is the only CL that touched C code.
On Wed, Jun 5, 2013 at 6:31 PM, richard.oudkerk <python-checkins at python.org>wrote:
http://hg.python.org/cpython/rev/0410bf251e10 changeset: 84045:0410bf251e10 user: Richard Oudkerk <shibturn at gmail.com> date: Wed Jun 05 23:29:30 2013 +0100 summary: Issue #17931: Resolve confusion on Windows between pids and process handles.
files: Include/longobject.h | 13 +++++++++++++ Misc/NEWS | 5 ++--- Modules/posixmodule.c | 25 +++++++++---------------- PC/msvcrtmodule.c | 5 +++-- PC/pyconfig.h | 4 ++-- 5 files changed, 29 insertions(+), 23 deletions(-)
diff --git a/Include/longobject.h b/Include/longobject.h --- a/Include/longobject.h +++ b/Include/longobject.h @@ -52,6 +52,19 @@ #error "sizeof(pidt) is neither sizeof(int), sizeof(long) or sizeof(long long)" #endif /* SIZEOFPIDT */ +#if SIZEOFVOIDP == SIZEOFINT +# define PyPARSEINTPTR "i" +# define PyPARSEUINTPTR "I" +#elif SIZEOFVOIDP == SIZEOFLONG +# define PyPARSEINTPTR "l" +# define PyPARSEUINTPTR "k" +#elif defined(SIZEOFLONGLONG) && SIZEOFVOIDP == SIZEOFLONGLONG +# define PyPARSEINTPTR "L" +# define PyPARSEUINTPTR "K" +#else +# error "void* different in size from int, long and long long" +#endif /* SIZEOFVOIDP */ + /* Used by Python/mystrtoul.c. */ #ifndef PyLIMITEDAPI PyAPIDATA(unsigned char) PyLongDigitValue[256]; diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -10,9 +10,8 @@ Core and Builtins ----------------- -- Issue #17931: Fix PyLongFromPid() on Windows 64-bit: processes are - identified by their HANDLE which is a pointer (and not a long, which is - smaller). +- Issue #17931: Resolve confusion on Windows between pids and process + handles. - Tweak the exception message when the magic number or size value in a bytecode file is truncated. diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -5014,11 +5014,7 @@ if (spawnval == -1) return posixerror(); else -#if SIZEOFLONG == SIZEOFVOIDP - return PyBuildValue("l", (long) spawnval); -#else - return PyBuildValue("L", (PYLONGLONG) spawnval); -#endif + return PyBuildValue(PyPARSEINTPTR, spawnval); } @@ -5104,11 +5100,7 @@ if (spawnval == -1) (void) posixerror(); else -#if SIZEOFLONG == SIZEOFVOIDP - res = PyBuildValue("l", (long) spawnval); -#else - res = PyBuildValue("L", (PYLONGLONG) spawnval); -#endif + res = PyBuildValue(PyPARSEINTPTR, spawnval); while (--envc >= 0) PyMemDEL(envlist[envc]); @@ -6178,16 +6170,17 @@ win32kill(PyObject *self, PyObject *args) { PyObject *result; - DWORD pid, sig, err; + pidt pid; + DWORD sig, err; HANDLE handle; - if (!PyArgParseTuple(args, "kk:kill", &pid, &sig)) + if (!PyArgParseTuple(args, PyPARSEPID "k:kill", &pid, &sig)) return NULL; /* Console processes which share a common console can be sent CTRL+C or CTRL+BREAK events, provided they handle said events. */ if (sig == CTRLCEVENT || sig == CTRLBREAKEVENT) { - if (GenerateConsoleCtrlEvent(sig, pid) == 0) { + if (GenerateConsoleCtrlEvent(sig, (DWORD)pid) == 0) { err = GetLastError(); PyErrSetFromWindowsErr(err); } @@ -6197,7 +6190,7 @@ /* If the signal is outside of what GenerateConsoleCtrlEvent can use, attempt to open and terminate the process. */ - handle = OpenProcess(PROCESSALLACCESS, FALSE, pid); + handle = OpenProcess(PROCESSALLACCESS, FALSE, (DWORD)pid); if (handle == NULL) { err = GetLastError(); return PyErrSetFromWindowsErr(err); @@ -6603,7 +6596,7 @@ Pyintptrt pid; int status, options; - if (!PyArgParseTuple(args, PyPARSEPID "i:waitpid", &pid, &options)) + if (!PyArgParseTuple(args, PyPARSEINTPTR "i:waitpid", &pid, &options)) return NULL; PyBEGINALLOWTHREADS pid = cwait(&status, pid, options); @@ -6612,7 +6605,7 @@ return posixerror(); /* shift the status left a byte so this is more like the POSIX waitpid */ - return PyBuildValue("Ni", PyLongFromPid(pid), status << 8); + return PyBuildValue(PyPARSEINTPTR "i", pid, status << 8); } #endif /* HAVEWAITPID || HAVECWAIT */ diff --git a/PC/msvcrtmodule.c b/PC/msvcrtmodule.c --- a/PC/msvcrtmodule.c +++ b/PC/msvcrtmodule.c @@ -113,11 +113,12 @@ static PyObject * msvcrtopenosfhandle(PyObject *self, PyObject *args) { - long handle; + Pyintptrt handle; int flags; int fd; - if (!PyArgParseTuple(args, "li:openosfhandle", &handle, &flags)) + if (!PyArgParseTuple(args, PyPARSEINTPTR "i:openosfhandle", + &handle, &flags)) return NULL; fd = openosfhandle(handle, flags); diff --git a/PC/pyconfig.h b/PC/pyconfig.h --- a/PC/pyconfig.h +++ b/PC/pyconfig.h @@ -723,8 +723,8 @@ /* The size of
wchart', as computed by sizeof. */_ _#define SIZEOFWCHART 2_ _-/* The size of
pidt' (HANDLE). */ -#define SIZEOFPIDT SIZEOFVOIDP +/* The size of `pidt', as computed by sizeof. */ +#define SIZEOFPIDT SIZEOFINT /* Define if you have the dl library (-ldl). */ /* #undef HAVELIBDL */ -- Repository URL: http://hg.python.org/cpython
Python-checkins mailing list Python-checkins at python.org http://mail.python.org/mailman/listinfo/python-checkins -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20130607/5b9cf444/attachment.html>
- Previous message: [Python-Dev] ssl improvements and testing question
- Next message: [Python-Dev] [Python-checkins] cpython: Issue #17931: Resolve confusion on Windows between pids and process handles.
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]