@@ -10810,8 +10810,9 @@ os_wait_impl(PyObject *module)
1081010810
1081110811
1081210812// This system call always crashes on older Android versions.
10813- #if defined(__linux__) && defined(__NR_pidfd_open) && \
10814- !(defined(__ANDROID__) && __ANDROID_API__ < 31)
10813+ #if defined(HAVE_PIDFD_OPEN) \
10814+ || (defined(__linux__) && defined(__NR_pidfd_open) \
10815+ && !(defined(__ANDROID__) && __ANDROID_API__ < 31))
1081510816/*[clinic input]
1081610817os.pidfd_open
1081710818 pid: pid_t
@@ -10827,7 +10828,11 @@ static PyObject *
1082710828os_pidfd_open_impl(PyObject *module, pid_t pid, unsigned int flags)
1082810829/*[clinic end generated code: output=5c7252698947dc41 input=03058b32c389f874]*/
1082910830{
10831+ #ifdef HAVE_PIDFD_OPEN
10832+ int fd = pidfd_open(pid, flags);
10833+ #else
1083010834 int fd = syscall(__NR_pidfd_open, pid, flags);
10835+ #endif
1083110836 if (fd < 0) {
1083210837 return posix_error();
1083310838 }
@@ -10836,8 +10841,9 @@ os_pidfd_open_impl(PyObject *module, pid_t pid, unsigned int flags)
1083610841#endif
1083710842
1083810843
10839- #if defined(__linux__) && defined(__NR_pidfd_getfd) && \
10840- !(defined(__ANDROID__) && __ANDROID_API__ < 31)
10844+ #if defined(HAVE_PIDFD_GETFD) \
10845+ || (defined(__linux__) && defined(__NR_pidfd_getfd) \
10846+ && !(defined(__ANDROID__) && __ANDROID_API__ < 31))
1084110847/*[clinic input]
1084210848os.pidfd_getfd
1084310849 pidfd: int
@@ -10856,7 +10862,11 @@ os_pidfd_getfd_impl(PyObject *module, int pidfd, int targetfd,
1085610862 unsigned int flags)
1085710863/*[clinic end generated code: output=e1a1415a13c7137f input=ef6417fb10deb1cc]*/
1085810864{
10865+ #ifdef HAVE_PIDFD_GETFD
10866+ int fd = pidfd_getfd(pidfd, targetfd, flags);
10867+ #else
1085910868 int fd = syscall(__NR_pidfd_getfd, pidfd, targetfd, flags);
10869+ #endif
1086010870 if (fd < 0) {
1086110871 return posix_error();
1086210872 }
0 commit comments