summaryrefslogtreecommitdiffstats
path: root/Modules/posixmodule.c
diff options
context:
space:
mode:
Diffstat (limited to 'Modules/posixmodule.c')
-rw-r--r--Modules/posixmodule.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index 524dc7e..51aa89e 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -7946,7 +7946,7 @@ os_getgid_impl(PyObject *module)
#endif /* HAVE_GETGID */
-#ifdef HAVE_GETPID
+#if defined(HAVE_GETPID)
/*[clinic input]
os.getpid
@@ -7957,9 +7957,13 @@ static PyObject *
os_getpid_impl(PyObject *module)
/*[clinic end generated code: output=9ea6fdac01ed2b3c input=5a9a00f0ab68aa00]*/
{
+#ifdef MS_WINDOWS_NON_DESKTOP
+ return PyLong_FromUnsignedLong(GetCurrentProcessId());
+#else
return PyLong_FromPid(getpid());
+#endif
}
-#endif /* HAVE_GETPID */
+#endif /* defined(HAVE_GETPID) */
#ifdef NGROUPS_MAX
#define MAX_GROUPS NGROUPS_MAX
@@ -8265,12 +8269,11 @@ static PyObject*
win32_getppid()
{
HANDLE snapshot;
- pid_t mypid;
PyObject* result = NULL;
BOOL have_record;
PROCESSENTRY32 pe;
- mypid = getpid(); /* This function never fails */
+ DWORD mypid = GetCurrentProcessId(); /* This function never fails */
snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
if (snapshot == INVALID_HANDLE_VALUE)
@@ -8279,9 +8282,9 @@ win32_getppid()
pe.dwSize = sizeof(pe);
have_record = Process32First(snapshot, &pe);
while (have_record) {
- if (mypid == (pid_t)pe.th32ProcessID) {
+ if (mypid == pe.th32ProcessID) {
/* We could cache the ulong value in a static variable. */
- result = PyLong_FromPid((pid_t)pe.th32ParentProcessID);
+ result = PyLong_FromUnsignedLong(pe.th32ParentProcessID);
break;
}