@@ -7946,7 +7946,7 @@ os_getgid_impl(PyObject *module)
79467946#endif /* HAVE_GETGID */
79477947
79487948
7949- #ifdef HAVE_GETPID
7949+ #if defined( HAVE_GETPID )
79507950/*[clinic input]
79517951os.getpid
79527952
@@ -7957,9 +7957,13 @@ static PyObject *
79577957os_getpid_impl (PyObject * module )
79587958/*[clinic end generated code: output=9ea6fdac01ed2b3c input=5a9a00f0ab68aa00]*/
79597959{
7960+ #ifdef MS_WINDOWS_NON_DESKTOP
7961+ return PyLong_FromUnsignedLong (GetCurrentProcessId ());
7962+ #else
79607963 return PyLong_FromPid (getpid ());
7964+ #endif
79617965}
7962- #endif /* HAVE_GETPID */
7966+ #endif /* defined( HAVE_GETPID) */
79637967
79647968#ifdef NGROUPS_MAX
79657969#define MAX_GROUPS NGROUPS_MAX
@@ -8265,12 +8269,11 @@ static PyObject*
82658269win32_getppid ()
82668270{
82678271 HANDLE snapshot ;
8268- pid_t mypid ;
82698272 PyObject * result = NULL ;
82708273 BOOL have_record ;
82718274 PROCESSENTRY32 pe ;
82728275
8273- mypid = getpid (); /* This function never fails */
8276+ DWORD mypid = GetCurrentProcessId (); /* This function never fails */
82748277
82758278 snapshot = CreateToolhelp32Snapshot (TH32CS_SNAPPROCESS , 0 );
82768279 if (snapshot == INVALID_HANDLE_VALUE )
@@ -8279,9 +8282,9 @@ win32_getppid()
82798282 pe .dwSize = sizeof (pe );
82808283 have_record = Process32First (snapshot , & pe );
82818284 while (have_record ) {
8282- if (mypid == ( pid_t ) pe .th32ProcessID ) {
8285+ if (mypid == pe .th32ProcessID ) {
82838286 /* We could cache the ulong value in a static variable. */
8284- result = PyLong_FromPid (( pid_t ) pe .th32ParentProcessID );
8287+ result = PyLong_FromUnsignedLong ( pe .th32ParentProcessID );
82858288 break ;
82868289 }
82878290
0 commit comments