Skip to content

Popen should use pidfd_open to implement a non-busy wait #83069

Closed

Description

@SpecLad
mannequin
BPO 38888
Nosy @gpshead, @vstinner, @benjaminp, @SpecLad

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = None
created_at = <Date 2019-11-21.21:43:43.189>
labels = ['type-feature', 'library', '3.9']
title = 'Popen should use pidfd_open to implement a non-busy wait'
updated_at = <Date 2019-11-21.22:20:50.812>
user = 'https://github.com/SpecLad'

bugs.python.org fields:

activity = <Date 2019-11-21.22:20:50.812>
actor = 'SpecLad'
assignee = 'none'
closed = False
closed_date = None
closer = None
components = ['Library (Lib)']
creation = <Date 2019-11-21.21:43:43.189>
creator = 'SpecLad'
dependencies = []
files = []
hgrepos = []
issue_num = 38888
keywords = []
message_count = 3.0
messages = ['357222', '357223', '357225']
nosy_count = 4.0
nosy_names = ['gregory.p.smith', 'vstinner', 'benjamin.peterson', 'SpecLad']
pr_nums = []
priority = 'normal'
resolution = None
stage = None
status = 'open'
superseder = None
type = 'enhancement'
url = 'https://bugs.python.org/issue38888'
versions = ['Python 3.9']

Linked PRs

Activity

  1. SpecLad commented on Nov 21, 2019

    SpecLadmannequin
    MannequinAuthor

    Popen.wait(timeout) is currently implemented on Unix-like systems using a busy wait, since the waitpid system call doesn't have a timeout argument.

    On Linux, it's now possible to do better than that. You can create a PID file descriptor using pidfd_create and poll that descriptor with the specified timeout. Popen.wait should make use of that.

  2. added
    stdlibStandard Library Python modules in the Lib/ directory
    type-featureA feature request or enhancement
    on Nov 21, 2019
  3. vstinner commented on Nov 21, 2019

    @vstinner
    Member

    os.pidfd_open() was added to Python 3.9. Do you mean pidfd_open()?

  4. SpecLad commented on Nov 21, 2019

    SpecLadmannequin
    MannequinAuthor

    Right, of course. I keep confusing it with timerfd_create.

  5. changed the title [-]Popen should use pidfd_create to implement a non-busy wait[/-] [+]Popen should use pidfd_open to implement a non-busy wait[/+] on Nov 21, 2019
  6. transferred this issue fromon Apr 10, 2022
  7. giampaolo commented on Jan 19, 2026

    @giampaolo
    Contributor

    Hi. Since I recently implemented this in psutil (giampaolo/psutil#2706), I decided to give this a try and port this change to the subprocess module. I created a PR which uses pidfd_open() on Linux and also adds support for macOS and BSD by using kqueue(): #144047.

  8. added a commit that references this issue on Jan 28, 2026
  9. vstinner commented on Jan 28, 2026

    @vstinner
    Member

    The feature is now implemented, I close the issue.

  10. added a commit that references this issue on Feb 15, 2026
  11. added 2 commits that reference this issue on Jul 29, 2026
  12. added a commit that references this issue on Aug 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.9 (EOL)end of lifestdlibStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancement

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions