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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants