nikademus79 / psutil

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

get_cpu_times(), access denied error on OSX #254

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
>>> p = psutil.Process(52799)
>>> p.cmdline
['/Applications/Utilities/Terminal.app/Contents/MacOS/Terminal', 
'-psn_0_33234864']
>>> p.get_cpu_times()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "psutil/__init__.py", line 364, in get_cpu_times
    return self._platform_impl.get_cpu_times()
  File "psutil/_psosx.py", line 97, in wrapper
    raise AccessDenied(self.pid, self._process_name)
psutil.error.AccessDenied: (pid=52799, name='Terminal')
>>> p.get_memory_info()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "psutil/__init__.py", line 375, in get_memory_info
    return self._platform_impl.get_memory_info()
  File "psutil/_psosx.py", line 97, in wrapper
    raise AccessDenied(self.pid, self._process_name)
psutil.error.AccessDenied: (pid=52799, name='Terminal')

What version of psutil are you using? What Python version?

psutil v0.4.1
python 2.7.2

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

OSX 10.6.8

I've tried for for a few different pids and seems to be common to all ... so 
its not 'Terminal' specific thing.

Original issue reported on code.google.com by g.willgo...@telluricresearch.com on 27 Feb 2012 at 6:01

GoogleCodeExporter commented 8 years ago
Are you running as root? 

You have to run your Python script as root in order to use psutil functions 
that read information from another process. This is part of the security model 
on OS X which does not allow one process to read from another process even if 
they are owned by the same user. Run your script as 'sudo python myscript.py' 
for example, and you should be able to get CPU information for other processes.

Original comment by jlo...@gmail.com on 27 Feb 2012 at 4:07