@@ -476,10 +476,6 @@ reset_signal_handlers(const sigset_t *child_sigmask)
476
476
#endif /* VFORK_USABLE */
477
477
478
478
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
-
483
479
/*
484
480
* This function is code executed in the child process immediately after
485
481
* (v)fork to set things up and call exec().
@@ -628,12 +624,12 @@ child_exec(char *const exec_array[],
628
624
#endif /* HAVE_SETGROUPS */
629
625
630
626
#ifdef HAVE_SETREGID
631
- if (gid != RESERVED_GID )
627
+ if (gid != ( gid_t ) - 1 )
632
628
POSIX_CALL (setregid (gid , gid ));
633
629
#endif /* HAVE_SETREGID */
634
630
635
631
#ifdef HAVE_SETREUID
636
- if (uid != RESERVED_UID )
632
+ if (uid != ( uid_t ) - 1 )
637
633
POSIX_CALL (setreuid (uid , uid ));
638
634
#endif /* HAVE_SETREUID */
639
635
@@ -957,7 +953,7 @@ subprocess_fork_exec(PyObject *module, PyObject *args)
957
953
#endif /* HAVE_SETGROUPS */
958
954
}
959
955
960
- gid_t gid = RESERVED_GID ;
956
+ gid_t gid = ( gid_t ) - 1 ;
961
957
if (gid_object != Py_None ) {
962
958
#ifdef HAVE_SETREGID
963
959
if (!_Py_Gid_Converter (gid_object , & gid ))
@@ -969,7 +965,7 @@ subprocess_fork_exec(PyObject *module, PyObject *args)
969
965
#endif /* HAVE_SETREUID */
970
966
}
971
967
972
- uid_t uid = RESERVED_UID ;
968
+ uid_t uid = ( uid_t ) - 1 ;
973
969
if (uid_object != Py_None ) {
974
970
#ifdef HAVE_SETREUID
975
971
if (!_Py_Uid_Converter (uid_object , & uid ))
@@ -998,7 +994,7 @@ subprocess_fork_exec(PyObject *module, PyObject *args)
998
994
/* Use vfork() only if it's safe. See the comment above child_exec(). */
999
995
sigset_t old_sigs ;
1000
996
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 ) {
1002
998
/* Block all signals to ensure that no signal handlers are run in the
1003
999
* child process while it shares memory with us. Note that signals
1004
1000
* used internally by C libraries won't be blocked by
0 commit comments