nikademus79 / psutil

Automatically exported from code.google.com/p/psutil
Other
0 stars 0 forks source link

Only the pid of the processes are returned with psutil 0.3.0 #207

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Execute the following code:
import psutil

for proc in psutil.process_iter():
  try:
    print proc
  except:
    pass

What is the expected output? What do you see instead?
- You get a list of all the processes in the system in this format: 
psutil.Process(<all process info>)

- You get a list of all the processes in the system only with the pid: 
psutil.Process(pid=15) The only process that displays more information is: 
psutil.Process(pid=0, name='kernel_task')

What version of psutil are you using? What Python version?
- psutil 0.3.0
- python 2.7

On what operating system? Is it 32bit or 64bit version?
Mac OS X 10.5.8 Leopard 64 bits
Mac OS X 10.6.8 Snow Leoperd 64 bits
Mac OS X 10.7 Lion 64 bits

Please provide any additional information below.
- If you, for example, replace in the code above "print proc" with "print 
proc.name", you will get an AccessDenied exception
- With previous versions of psutil this worked fine but in 10.7 Lion.

Original issue reported on code.google.com by fdv...@gmail.com on 15 Sep 2011 at 3:33

GoogleCodeExporter commented 8 years ago
If you run this script as end user and as root what are the results? 

import psutil

for proc in psutil.process_iter():
    try:
        print proc
    except psutil.AccessDenied:
        print "AccessDenied exception for PID %s" % (proc.pid)
    except Exception,e:
        print "Other exception: %s" % (e)

I suspect this is a legitimate access denied error; OS X has very stringent 
security restrictions. I believe in 10.7 the security management prevents you 
from reading information from another process, even when the querying process 
is run by the same user ID as the process you're trying to read info for. 

Original comment by jlo...@gmail.com on 15 Sep 2011 at 3:49

GoogleCodeExporter commented 8 years ago
But the problem is that it does not only happen with 10.7, but also with 10.5 
and 10.6 and previous versions of psutil worked fine with 10.5 and 10.6.

Original comment by fdv...@gmail.com on 15 Sep 2011 at 3:59

GoogleCodeExporter commented 8 years ago
I ran the script on 10.6.8 and it works as I would expect, using the current 
SVN version of psutil. If you run it as root you should see information for all 
the processes.

Original comment by jlo...@gmail.com on 15 Sep 2011 at 4:36

GoogleCodeExporter commented 8 years ago
I continue getting only the pid of the processes. I used "sudo su".
Does the script work as expected if you replace "print proc" with "print 
proc.name"? I get a lot of AccessDenied exceptions.

Original comment by fdv...@gmail.com on 16 Sep 2011 at 8:30

GoogleCodeExporter commented 8 years ago
"sudo su" does not make any sense.. do you mean you used sudo to  run the 
script? It should be run like the below example, taken from my system. 

[user@host ]$ sudo python osx_process_iter.py 
Password:
psutil.Process(pid=66608, name='Python')
psutil.Process(pid=4628, name='AppleSpell')
psutil.Process(pid=4008, name='DashboardClient')
psutil.Process(pid=3963, name='pboard')
psutil.Process(pid=3960, name='fontd')
psutil.Process(pid=3958, name='Finder')
psutil.Process(pid=3957, name='SystemUIServer')
psutil.Process(pid=3956, name='Dock')
psutil.Process(pid=3939, name='WindowServer')
psutil.Process(pid=3938, name='loginwindow')
psutil.Process(pid=1659, name='dbus-daemon')

[...]

Original comment by jlo...@gmail.com on 16 Sep 2011 at 11:55

GoogleCodeExporter commented 8 years ago

Original comment by jlo...@gmail.com on 18 Sep 2011 at 6:54

GoogleCodeExporter commented 8 years ago
I'm going to close this one as invalid for inactivity for now.
If you still think this is a bug in psutil just reply and I'll reopen.

Original comment by g.rodola on 22 Oct 2011 at 11:24