Skip to main content

pidfd

CI CodeQL OpenSSF Scorecard PyPI License: 0BSD

Dependency-free Python bindings for Linux pidfds. A pidfd is a file descriptor referring to a process: a stable handle that can never hit a recycled pid, becomes readable when the task exits, can be waited on with waitid(2), and can duplicate the task's file descriptors with pidfd_getfd(2). Everything goes through pidfd_open(2), pidfd_send_signal(2), pidfd_getfd(2) and waitid(2) via ctypes. There are no runtime dependencies.

Requires Python 3.10+ and Linux.

Install

pip install pidfd

Usage

import select, signal, subprocess
from pidfd import PidFd, WaitCode

proc = subprocess.Popen(["sleep", "30"])
with PidFd.open(proc.pid) as pf:
    # poll(2) reports the fd readable once the task is a zombie
    pf.signal(signal.SIGKILL)

    poller = select.poll()
    poller.register(pf.fileno(), select.POLLIN)
    poller.poll()

    result = pf.wait()  # waitid(P_PIDFD)
    assert result.code == WaitCode.CLD_KILLED

PidFd.open(pid, OpenFlag.NONBLOCK) makes wait() fail with EAGAIN instead of blocking. pf.getfd(fd) duplicates one of the target's open fds (ptrace access rules apply).

Development

uv sync --group dev
make check

License: 0BSD. Quad4 Software, https://quad4.io

Release files for pidfd 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pidfd 0.1.0
File Size Uploaded
pidfd-0.1.0.tar.gz 67.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pidfd 0.1.0
File Interpreter ABI Platform
pidfd-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 75.4 kB

Release files / pidfd-0.1.0.tar.gz

Download URL pidfd-0.1.0.tar.gz
Size 67.1 kB
Tags Source
SHA-256 checksum
How to use checksums
ea4967821d33fff7800b8a3fa9a1ef4e295803bdd9430e7bdb20210b1b35d807
BLAKE2b-256 checksum
How to use checksums
31b89dddd88627eebf0e844539e509804bff343a458779bec62de7e8423f0125
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 22, 2026.

Transparency log

Release files / pidfd-0.1.0-py3-none-any.whl

Download URL pidfd-0.1.0-py3-none-any.whl
Size 8.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
675838ea1461068e2c19017354b5db711b69f73936c6d553a9e2ed6b013dd616
BLAKE2b-256 checksum
How to use checksums
e1d167e9c84a5db7417b866fd006ace3754b04a56e478a3c6bde74fecff90572
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 22, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page