Differently from UNIX, the assumption in the code that ERROR_ACCESS_DENIED means there's a process to deny access to (hence it exists) is wrong. We therefore remove this assumption and also write a test case which ensures that pid_exists(), Process() and pids() APIs are all consistent with each other.
As a bonus, I also discovered there are "hidden" PIDs on Windows (oh well!).
Summary
Description
On Windows,
pid_exists()
may return True butpsutil.Process()
raisesNoSuchProcess
. Internally, this happens because of: https://github.com/giampaolo/psutil/blob/034a1a6996d4ff5116fc45a9c5ed8477d0d73d37/psutil/arch/windows/proc_utils.c#L176-L178.Differently from UNIX, the assumption in the code that ERROR_ACCESS_DENIED means there's a process to deny access to (hence it exists) is wrong. We therefore remove this assumption and also write a test case which ensures that
pid_exists()
,Process()
andpids()
APIs are all consistent with each other.As a bonus, I also discovered there are "hidden" PIDs on Windows (oh well!).