Skip to content

os.pidf_* functions not available when building with older glibc and modern Linux UAPI headers #153463

Description

@jjhelmus

Bug report

Bug description:

This is an edge case but occurred in python-build-standalone, astral-sh/python-build-standalone#1163.

On systems using glibc that predates the addition of SYS_getrandom, os.pidfd_open() and os.pidfd_getfd() will not be built even when the required __NR_pidfd_* syscall macros are available. These macros were added to the kernel UAPI much later than getrandom but it is possible to build with modern kernel UAPI headers while using an older glibc. For example, this approach is taken in python-build-standalone to allow newer kernel syscalls to be used while maintaining compatibility with older glibc versions.

The fix is straightforward, guard the include with HAVE_SYS_SYSCALL_H rather than HAVE_GETRANDOM_SYSCALL.

CPython versions tested on:

3.15

Operating systems tested on:

Linux

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-bugAn unexpected behavior, bug, or error

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions