Skip to content

Commit 7c4724f

Browse files
committed
gh-123014: Disable pidfd API on older Android versions (#124458)
(cherry picked from commit c58c572)
1 parent 2f25d85 commit 7c4724f

File tree

7 files changed

+18
-10
lines changed

7 files changed

+18
-10
lines changed

Doc/library/os.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4572,7 +4572,7 @@ written in Python, such as a mail server's external command delivery program.
45724572

45734573
See the :manpage:`pidfd_open(2)` man page for more details.
45744574

4575-
.. availability:: Linux >= 5.3
4575+
.. availability:: Linux >= 5.3, Android >= :func:`build-time <sys.getandroidapilevel>` API level 31
45764576
.. versionadded:: 3.9
45774577

45784578
.. data:: PIDFD_NONBLOCK

Doc/library/signal.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ The :mod:`signal` module defines the following functions:
411411

412412
See the :manpage:`pidfd_send_signal(2)` man page for more information.
413413

414-
.. availability:: Linux >= 5.1
414+
.. availability:: Linux >= 5.1, Android >= :func:`build-time <sys.getandroidapilevel>` API level 31
415415
.. versionadded:: 3.9
416416

417417

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
:func:`os.pidfd_open` and :func:`signal.pidfd_send_signal` are now
2+
unavailable when building against Android API levels older than 31, since
3+
the underlying system calls may cause a crash.

Modules/clinic/posixmodule.c.h

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/clinic/signalmodule.c.h

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/posixmodule.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10102,7 +10102,10 @@ os_wait_impl(PyObject *module)
1010210102
}
1010310103
#endif /* HAVE_WAIT */
1010410104

10105-
#if defined(__linux__) && defined(__NR_pidfd_open)
10105+
10106+
// This system call always crashes on older Android versions.
10107+
#if defined(__linux__) && defined(__NR_pidfd_open) && \
10108+
!(defined(__ANDROID__) && __ANDROID_API__ < 31)
1010610109
/*[clinic input]
1010710110
os.pidfd_open
1010810111
pid: pid_t

Modules/signalmodule.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1299,7 +1299,9 @@ signal_pthread_kill_impl(PyObject *module, unsigned long thread_id,
12991299
#endif /* #if defined(HAVE_PTHREAD_KILL) */
13001300

13011301

1302-
#if defined(__linux__) && defined(__NR_pidfd_send_signal)
1302+
// This system call always crashes on older Android versions.
1303+
#if defined(__linux__) && defined(__NR_pidfd_send_signal) && \
1304+
!(defined(__ANDROID__) && __ANDROID_API__ < 31)
13031305
/*[clinic input]
13041306
signal.pidfd_send_signal
13051307

0 commit comments

Comments
 (0)