Fix #2793: process_iter() skips zombie processes#2818
Open
EhteshamSid wants to merge 1 commit intogiampaolo:masterfrom
Open
Fix #2793: process_iter() skips zombie processes#2818EhteshamSid wants to merge 1 commit intogiampaolo:masterfrom
EhteshamSid wants to merge 1 commit intogiampaolo:masterfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2793.
ZombieProcessis a subclass ofNoSuchProcess, so theexcept NoSuchProcessclause in the inner loop ofprocess_iter()was catching it and callingremove(pid)- same as if the process had disappeared. That meant zombies were silently dropped from the iteration instead of being yielded.The fix adds an explicit
except ZombieProcesshandler beforeexcept NoSuchProcessand yields the process. Theif proc is not Noneguard covers the case whereZombieProcessis raised duringadd(pid)beforeprocis assigned (shouldn't happen in practice sinceProcess.__init__catches it internally, but worth being safe about).Added
test_emulate_zombiealongside the existingtest_emulate_nsp/test_emulate_access_deniedtests which do the same kind of mock-based check.