@@ -476,10 +476,6 @@ reset_signal_handlers(const sigset_t *child_sigmask)
476476#endif /* VFORK_USABLE */
477477
478478
479- /* To avoid signeness churn on platforms where gid and uid are unsigned. */
480- #define RESERVED_GID (gid_t)-1
481- #define RESERVED_UID (uid_t)-1
482-
483479/*
484480 * This function is code executed in the child process immediately after
485481 * (v)fork to set things up and call exec().
@@ -628,12 +624,12 @@ child_exec(char *const exec_array[],
628624#endif /* HAVE_SETGROUPS */
629625
630626#ifdef HAVE_SETREGID
631- if (gid != RESERVED_GID )
627+ if (gid != ( gid_t ) - 1 )
632628 POSIX_CALL (setregid (gid , gid ));
633629#endif /* HAVE_SETREGID */
634630
635631#ifdef HAVE_SETREUID
636- if (uid != RESERVED_UID )
632+ if (uid != ( uid_t ) - 1 )
637633 POSIX_CALL (setreuid (uid , uid ));
638634#endif /* HAVE_SETREUID */
639635
@@ -957,7 +953,7 @@ subprocess_fork_exec(PyObject *module, PyObject *args)
957953#endif /* HAVE_SETGROUPS */
958954 }
959955
960- gid_t gid = RESERVED_GID ;
956+ gid_t gid = ( gid_t ) - 1 ;
961957 if (gid_object != Py_None ) {
962958#ifdef HAVE_SETREGID
963959 if (!_Py_Gid_Converter (gid_object , & gid ))
@@ -969,7 +965,7 @@ subprocess_fork_exec(PyObject *module, PyObject *args)
969965#endif /* HAVE_SETREUID */
970966 }
971967
972- uid_t uid = RESERVED_UID ;
968+ uid_t uid = ( uid_t ) - 1 ;
973969 if (uid_object != Py_None ) {
974970#ifdef HAVE_SETREUID
975971 if (!_Py_Uid_Converter (uid_object , & uid ))
@@ -998,7 +994,7 @@ subprocess_fork_exec(PyObject *module, PyObject *args)
998994 /* Use vfork() only if it's safe. See the comment above child_exec(). */
999995 sigset_t old_sigs ;
1000996 if (preexec_fn == Py_None && allow_vfork &&
1001- uid == RESERVED_UID && gid == RESERVED_GID && groups_list == Py_None ) {
997+ uid == ( uid_t ) - 1 && gid == ( gid_t ) - 1 && groups_list == Py_None ) {
1002998 /* Block all signals to ensure that no signal handlers are run in the
1003999 * child process while it shares memory with us. Note that signals
10041000 * used internally by C libraries won't be blocked by
0 commit comments