Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

psutil.Process(4).exe has inconsistent behavior between WinXP and Win7 #414

Closed
giampaolo opened this issue May 23, 2014 · 5 comments
Closed

Comments

@giampaolo
Copy link
Owner

From [email protected] on July 28, 2013 18:10:38

What steps will reproduce the problem?  
1. psutil.Process(4).exe   (inadvertantly from calling as_dict())

Drilled down to the lowest call:
>>> _psutil_mswindows.get_process_exe(4)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
WindowsError: [Error 5] Access is denied

>>> _psutil_mswindows.get_process_exe(4)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
WindowsError: [Error 87] The parameter is incorrect 

What is the expected output?  
psutil._error.AccessDenied: (pid=4) 

What do you see instead?  
WindowsError [Error 87] The parameter is incorrect 

What version of psutil are you using? What Python version?  
psutil tip (02ce4f7587ef)
Python 2.7.5 

On what operating system? Is it 32bit or 64bit version?  
Win7SP1 x86
WinXPSP3 x86 

Please provide any additional information below.  
This is because of the inconsistent errno returned by GetProcessImageFileName.  
We can't control what Windows returns to us but we can try to make it 
consistent to the end user.  

[proc.as_dict(ad_value="ACCESS DENIED") for proc in psutil.process_iter()] 
works gracefully on Win7.  On WinXP, the exception bubbles up and breaks execution.

In _psmswindows.py:wrap_exceptions a check is made to see if the WindowsError 
errno is in the a predefined ACCESS_DENIED_SET.  In the case of WinXP, the 
error raised is ERROR_INVALID_PARAMETER which is not in this set.

I'm not sure when the errno changes between Windows versions, I only have WinXP 
and Win7 to test with.

Original issue: http://code.google.com/p/psutil/issues/detail?id=414

@giampaolo
Copy link
Owner Author

From g.rodola on July 29, 2013 07:01:15

I fixed this in revision 5c64fe6dcdef .
I didn't actually tested it on Win XP but I assume it works.

Status: FixedInHG
Labels: -Priority-Low Priority-Medium OpSys-Windows Milestone-1.1.0

@giampaolo
Copy link
Owner Author

From [email protected] on July 29, 2013 07:06:45

Confirmed patch works.

@giampaolo
Copy link
Owner Author

From g.rodola on August 26, 2013 03:25:02

Labels: -OpSys-WindowsXP

@giampaolo
Copy link
Owner Author

From g.rodola on September 28, 2013 03:06:18

Status: Fixed

@giampaolo
Copy link
Owner Author

From g.rodola on September 28, 2013 10:32:46

Closing out as fixed. Release 1.1.0 is now available for download.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant