Skip to content

gh-151179: Fix pidfd leak in asyncio _PidfdChildWatcher - #151186

Merged
kumaraditya303 merged 6 commits into
python:mainfrom
deadlovelll:gh-151179-pidfd-leak
Jun 11, 2026
Merged

gh-151179: Fix pidfd leak in asyncio _PidfdChildWatcher#151186
kumaraditya303 merged 6 commits into
python:mainfrom
deadlovelll:gh-151179-pidfd-leak

Conversation

@deadlovelll

Copy link
Copy Markdown
Contributor

_PidfdChildWatcher._do_wait() left os.close(pidfd) outside the cleanup path. The pidfd leaked when waitpid() raising anything other than ChildProcessError. Moving os.close() into a finally block closes the descriptor while still letting the exception propagate.

For more details see gh-151179

Comment thread Lib/asyncio/unix_events.py Outdated
Comment thread Lib/test/test_asyncio/test_unix_events.py Outdated
@kumaraditya303
kumaraditya303 enabled auto-merge (squash) June 11, 2026 11:21
@kumaraditya303
kumaraditya303 merged commit a05b9cd into python:main Jun 11, 2026
53 checks passed
philthompson10 pushed a commit to philthompson10/cpython that referenced this pull request Jun 17, 2026
@kumaraditya303 kumaraditya303 added needs backport to 3.14 bugs and security fixes needs backport to 3.15 pre-release feature fixes, bugs and security fixes labels Sep 11, 2026
@miss-islington-app

Copy link
Copy Markdown

Thanks @deadlovelll for the PR, and @kumaraditya303 for merging it 🌮🎉.. I'm working now to backport this PR to: 3.15.
🐍🍒⛏🤖

@bedevere-app

bedevere-app Bot commented Sep 11, 2026

Copy link
Copy Markdown

GH-157318 is a backport of this pull request to the 3.15 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.15 pre-release feature fixes, bugs and security fixes label Sep 11, 2026
hugovk pushed a commit that referenced this pull request Sep 11, 2026
…1186) (#157318)

Co-authored-by: Timofei <128279579+deadlovelll@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants