Closed GoogleCodeExporter closed 9 years ago
Hi Pierre,
If you run this test script as root, what are the results? Can you post the
contents of your test_psutil.py just for clarity's sake?
The OS X security model is very strict and only root can read information from
another process, unless the application is signed and specifically given access
to another app. That applies even to other processes opened by your user
account; you still need to be root to read the information. The unix utils like
ps and top on OS X are setuid root in order to access this information.
-Jay
Original comment by jlo...@gmail.com
on 30 Sep 2011 at 2:50
$ cat /tmp/test-psutil.py
#!/usr/bin/env python
import psutil
import subprocess
sp = subprocess.Popen(['sleep', '30'])
p = psutil.Process(sp.pid)
print p.get_threads()
$ sudo /tmp/test-psutil.py
[thread(id=1, user_time=0.000625, system_time=0.001875)]
$
( tested code from svn also and got same error but it sounds predictable from
your explicationf of OS X security model.
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/tmp/psutil-read-only/install//lib/python2.7/site-packages/psutil-0.3.1-py2.7-macosx-10.5-i386.egg/psutil/__init__.py", line 286, in get_threads
return self._platform_impl.get_process_threads()
File "/tmp/psutil-read-only/install//lib/python2.7/site-packages/psutil-0.3.1-py2.7-macosx-10.5-i386.egg/psutil/_psosx.py", line 92, in wrapper
raise AccessDenied(self.pid, self._process_name)
psutil.error.AccessDenied: (pid=9124)
)
Original comment by pierre.g...@gmail.com
on 30 Sep 2011 at 3:17
Yeah, this looks like expected results for the OS X security model. In general
psutil is only really useful on OS X when run as root, or when the process
you're querying is the current process. There is some information that is
obtainable for other processes, but only basic things like PID and name,
everything else that uses the OS X specific interfaces is limited by this
security restriction.
I'll close this defect out since it's just a feature of OS X.
Original comment by jlo...@gmail.com
on 30 Sep 2011 at 3:26
Original issue reported on code.google.com by
pierre.g...@gmail.com
on 30 Sep 2011 at 2:47