From 81a85f18b6393001df42f20b58e3435a74ed0fe2 Mon Sep 17 00:00:00 2001 From: Martin Fischer Date: Mon, 28 Feb 2022 06:02:15 +0100 Subject: [PATCH] stdlib: Add os.pidfd_open(pid) --- stdlib/os/__init__.pyi | 3 +++ stdlib/posix.pyi | 3 ++- tests/stubtest_allowlists/linux-py310.txt | 2 -- tests/stubtest_allowlists/linux-py39.txt | 2 -- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/stdlib/os/__init__.pyi b/stdlib/os/__init__.pyi index 8c284c8d1..3f8b43849 100644 --- a/stdlib/os/__init__.pyi +++ b/stdlib/os/__init__.pyi @@ -1024,3 +1024,6 @@ if sys.version_info >= (3, 8): if sys.version_info >= (3, 9): def waitstatus_to_exitcode(status: int) -> int: ... + + if sys.platform == "linux": + def pidfd_open(pid: int, flags: int = ...) -> int: ... diff --git a/stdlib/posix.pyi b/stdlib/posix.pyi index 9f658039b..b0b3fc4d2 100644 --- a/stdlib/posix.pyi +++ b/stdlib/posix.pyi @@ -273,7 +273,8 @@ if sys.platform != "win32": from os import CLD_KILLED as CLD_KILLED, CLD_STOPPED as CLD_STOPPED, waitstatus_to_exitcode as waitstatus_to_exitcode if sys.platform == "linux": - from os import P_PIDFD as P_PIDFD + from os import P_PIDFD as P_PIDFD, pidfd_open as pidfd_open + if sys.version_info >= (3, 8): from os import ( POSIX_SPAWN_CLOSE as POSIX_SPAWN_CLOSE, diff --git a/tests/stubtest_allowlists/linux-py310.txt b/tests/stubtest_allowlists/linux-py310.txt index 995d80026..38ab16dc4 100644 --- a/tests/stubtest_allowlists/linux-py310.txt +++ b/tests/stubtest_allowlists/linux-py310.txt @@ -29,7 +29,6 @@ os.copy_file_range os.eventfd os.eventfd_read os.eventfd_write -os.pidfd_open os.splice posix.EFD_[A-Z]+ posix.SPLICE_[A-Z_]+ @@ -37,5 +36,4 @@ posix.copy_file_range posix.eventfd posix.eventfd_read posix.eventfd_write -posix.pidfd_open posix.splice diff --git a/tests/stubtest_allowlists/linux-py39.txt b/tests/stubtest_allowlists/linux-py39.txt index 1975288fa..eb8a71b49 100644 --- a/tests/stubtest_allowlists/linux-py39.txt +++ b/tests/stubtest_allowlists/linux-py39.txt @@ -3,6 +3,4 @@ select.epoll.register # Exists at runtime, but missing from stubs os.copy_file_range -os.pidfd_open posix.copy_file_range -posix.pidfd_open