Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
162b6335
Commit
162b6335
authored
Jun 05, 2013
by
Richard Oudkerk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #17931: Resolve confusion on Windows between pids and process handles.
parent
8c5d6c31
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
29 additions
and
23 deletions
+29
-23
Include/longobject.h
Include/longobject.h
+13
-0
Misc/NEWS
Misc/NEWS
+2
-3
Modules/posixmodule.c
Modules/posixmodule.c
+9
-16
PC/msvcrtmodule.c
PC/msvcrtmodule.c
+3
-2
PC/pyconfig.h
PC/pyconfig.h
+2
-2
No files found.
Include/longobject.h
View file @
162b6335
...
...
@@ -52,6 +52,19 @@ PyAPI_FUNC(PyObject *) PyLong_GetInfo(void);
#error "sizeof(pid_t) is neither sizeof(int), sizeof(long) or sizeof(long long)"
#endif
/* SIZEOF_PID_T */
#if SIZEOF_VOID_P == SIZEOF_INT
# define _Py_PARSE_INTPTR "i"
# define _Py_PARSE_UINTPTR "I"
#elif SIZEOF_VOID_P == SIZEOF_LONG
# define _Py_PARSE_INTPTR "l"
# define _Py_PARSE_UINTPTR "k"
#elif defined(SIZEOF_LONG_LONG) && SIZEOF_VOID_P == SIZEOF_LONG_LONG
# define _Py_PARSE_INTPTR "L"
# define _Py_PARSE_UINTPTR "K"
#else
# error "void* different in size from int, long and long long"
#endif
/* SIZEOF_VOID_P */
/* Used by Python/mystrtoul.c. */
#ifndef Py_LIMITED_API
PyAPI_DATA
(
unsigned
char
)
_PyLong_DigitValue
[
256
];
...
...
Misc/NEWS
View file @
162b6335
...
...
@@ -10,9 +10,8 @@ What's New in Python 3.4.0 Alpha 1?
Core and Builtins
-----------------
- Issue #17931: Fix PyLong_FromPid() 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.
...
...
Modules/posixmodule.c
View file @
162b6335
...
...
@@ -5014,11 +5014,7 @@ posix_spawnv(PyObject *self, PyObject *args)
if
(
spawnval
==
-
1
)
return
posix_error
();
else
#if SIZEOF_LONG == SIZEOF_VOID_P
return
Py_BuildValue
(
"l"
,
(
long
)
spawnval
);
#else
return
Py_BuildValue
(
"L"
,
(
PY_LONG_LONG
)
spawnval
);
#endif
return
Py_BuildValue
(
_Py_PARSE_INTPTR
,
spawnval
);
}
...
...
@@ -5104,11 +5100,7 @@ posix_spawnve(PyObject *self, PyObject *args)
if
(
spawnval
==
-
1
)
(
void
)
posix_error
();
else
#if SIZEOF_LONG == SIZEOF_VOID_P
res
=
Py_BuildValue
(
"l"
,
(
long
)
spawnval
);
#else
res
=
Py_BuildValue
(
"L"
,
(
PY_LONG_LONG
)
spawnval
);
#endif
res
=
Py_BuildValue
(
_Py_PARSE_INTPTR
,
spawnval
);
while
(
--
envc
>=
0
)
PyMem_DEL
(
envlist
[
envc
]);
...
...
@@ -6178,16 +6170,17 @@ static PyObject *
win32_kill
(
PyObject
*
self
,
PyObject
*
args
)
{
PyObject
*
result
;
DWORD
pid
,
sig
,
err
;
pid_t
pid
;
DWORD
sig
,
err
;
HANDLE
handle
;
if
(
!
PyArg_ParseTuple
(
args
,
"k
k:kill"
,
&
pid
,
&
sig
))
if
(
!
PyArg_ParseTuple
(
args
,
_Py_PARSE_PID
"
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
==
CTRL_C_EVENT
||
sig
==
CTRL_BREAK_EVENT
)
{
if
(
GenerateConsoleCtrlEvent
(
sig
,
pid
)
==
0
)
{
if
(
GenerateConsoleCtrlEvent
(
sig
,
(
DWORD
)
pid
)
==
0
)
{
err
=
GetLastError
();
PyErr_SetFromWindowsErr
(
err
);
}
...
...
@@ -6197,7 +6190,7 @@ win32_kill(PyObject *self, PyObject *args)
/* If the signal is outside of what GenerateConsoleCtrlEvent can use,
attempt to open and terminate the process. */
handle
=
OpenProcess
(
PROCESS_ALL_ACCESS
,
FALSE
,
pid
);
handle
=
OpenProcess
(
PROCESS_ALL_ACCESS
,
FALSE
,
(
DWORD
)
pid
);
if
(
handle
==
NULL
)
{
err
=
GetLastError
();
return
PyErr_SetFromWindowsErr
(
err
);
...
...
@@ -6603,7 +6596,7 @@ posix_waitpid(PyObject *self, PyObject *args)
Py_intptr_t
pid
;
int
status
,
options
;
if
(
!
PyArg_ParseTuple
(
args
,
_Py_PARSE_
PID
"i:waitpid"
,
&
pid
,
&
options
))
if
(
!
PyArg_ParseTuple
(
args
,
_Py_PARSE_
INTPTR
"i:waitpid"
,
&
pid
,
&
options
))
return
NULL
;
Py_BEGIN_ALLOW_THREADS
pid
=
_cwait
(
&
status
,
pid
,
options
);
...
...
@@ -6612,7 +6605,7 @@ posix_waitpid(PyObject *self, PyObject *args)
return
posix_error
();
/* shift the status left a byte so this is more like the POSIX waitpid */
return
Py_BuildValue
(
"Ni"
,
PyLong_FromPid
(
pid
)
,
status
<<
8
);
return
Py_BuildValue
(
_Py_PARSE_INTPTR
"i"
,
pid
,
status
<<
8
);
}
#endif
/* HAVE_WAITPID || HAVE_CWAIT */
...
...
PC/msvcrtmodule.c
View file @
162b6335
...
...
@@ -113,11 +113,12 @@ os.O_BINARY.");
static
PyObject
*
msvcrt_open_osfhandle
(
PyObject
*
self
,
PyObject
*
args
)
{
long
handle
;
Py_intptr_t
handle
;
int
flags
;
int
fd
;
if
(
!
PyArg_ParseTuple
(
args
,
"li:open_osfhandle"
,
&
handle
,
&
flags
))
if
(
!
PyArg_ParseTuple
(
args
,
_Py_PARSE_INTPTR
"i:open_osfhandle"
,
&
handle
,
&
flags
))
return
NULL
;
fd
=
_open_osfhandle
(
handle
,
flags
);
...
...
PC/pyconfig.h
View file @
162b6335
...
...
@@ -723,8 +723,8 @@ Py_NO_ENABLE_SHARED to find out. Also support MS_NO_COREDLL for b/w compat */
/* The size of `wchar_t', as computed by sizeof. */
#define SIZEOF_WCHAR_T 2
/* The size of `pid_t'
(HANDLE)
. */
#define SIZEOF_PID_T SIZEOF_
VOID_P
/* The size of `pid_t'
, as computed by sizeof
. */
#define SIZEOF_PID_T SIZEOF_
INT
/* Define if you have the dl library (-ldl). */
/* #undef HAVE_LIBDL */
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment