Skip to content

Commit c58c572

Browse files
authored
gh-123014: Disable pidfd API on older Android versions (#124458)
1 parent 461c12b commit c58c572

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
@@ -4602,7 +4602,7 @@ written in Python, such as a mail server's external command delivery program.
46024602

46034603
See the :manpage:`pidfd_open(2)` man page for more details.
46044604

4605-
.. availability:: Linux >= 5.3
4605+
.. availability:: Linux >= 5.3, Android >= :func:`build-time <sys.getandroidapilevel>` API level 31
46064606
.. versionadded:: 3.9
46074607

46084608
.. 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
@@ -10121,7 +10121,10 @@ os_wait_impl(PyObject *module)
1012110121
}
1012210122
#endif /* HAVE_WAIT */
1012310123

10124-
#if defined(__linux__) && defined(__NR_pidfd_open)
10124+
10125+
// This system call always crashes on older Android versions.
10126+
#if defined(__linux__) && defined(__NR_pidfd_open) && \
10127+
!(defined(__ANDROID__) && __ANDROID_API__ < 31)
1012510128
/*[clinic input]
1012610129
os.pidfd_open
1012710130
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)