Closed GoogleCodeExporter closed 8 years ago
Please provide some more info.
Do you get AccessDenied exceptions?
What if you run:
>>> import psutil, os
>>> p = psutil.Process(os.getpid())
>>> p.name
...
>>> p.cmdline
...
[ other method calls here ]
Does it make any difference if run as root or limited user?
Original comment by g.rodola
on 14 Jun 2011 at 8:24
- I get an AccessDenied exception with p.name, p.exe, p.cmdline and p.path
- I get nothing with p.pid, p.ppid and p.parent (I mean, no exception and no
result).
- Same result if I execute: "python a.py" or "sudo python a.py"
Original comment by fdv...@gmail.com
on 14 Jun 2011 at 8:39
Then I guess OSX Lion is even more restricted than previous OSX versions on
which we already experienced serious permission limitations (see issue 108).
I'll leave this one to Jay but my guess is that we can't do much about it other
than providing instructions on how to run psutil via setuid, assuming it is a
valid workaround in the first place.
Original comment by g.rodola
on 14 Jun 2011 at 8:55
I don't have access to a 10.7 machine so I have no way to debug this presently.
It sounds like the kernel structures or syscalls may have changed again in
10.7, or it's possible there is a new security model as Giampaolo had
suggested. The AccessDenied results would seem to indicate we're not being
allowed to read process information but I'm not sure why there would be no
result for pid, ppid, cmdline and path.
Did you run the suggested code exactly as shown, with "p =
psutil.Process(os.getpid())" ? It seems strange that we would be prevented from
reading process information for the calling process, even accounting for some
new security restriction.
-Jay
Original comment by jlo...@gmail.com
on 14 Jun 2011 at 11:40
Yes, I executed exactly "p = psutil.Process(os.getpid())". As far as I know,
10.7 has got changes in the permissions system.
Original comment by fdv...@gmail.com
on 14 Jun 2011 at 1:50
I get this error on 10.6 as well, both as root and as a normal user.
Original comment by turbina...@gmail.com
on 18 Sep 2011 at 6:45
The example given in this issue does not give us any information to work with
since it's skipping/passing all the exceptions. I think this is the same as
Issue 207 so it would be worth trying the same thing I suggested there. Try the
below script as root - e.g. save to psutil_proc_iter.py and run as "sudo python
psutil_proc_iter.py"
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)
Let us know the results so we can narrow this down.
Original comment by jlo...@gmail.com
on 18 Sep 2011 at 6:53
I get the following on OS X 1.7.3
$ sudo python psutil_proc_iter.py
Password:
psutil.Process(pid=65030, name='Python')
psutil.Process(pid=65029, name='auditd')
psutil.Process(pid=65028, name='sudo')
psutil.Process(pid=65027, name='Python')
psutil.Process(pid=64962, name='bash')
psutil.Process(pid=64961, name='login')
...
and without sudo:
$ python psutil_proc_iter.py
psutil.Process(pid=65094, name='Python')
psutil.Process(pid=65093, name='sleep')
psutil.Process(pid=64962, name='bash')
psutil.Process(pid=64961)
psutil.Process(pid=64658, name='bash')
psutil.Process(pid=64657)
...
It seems that only the names of those processes show up which are owned by the
user executing the python program.
Original comment by ske...@googlemail.com
on 5 Apr 2012 at 2:26
This should have been fixed in issue 297.
Closing it out.
Original comment by g.rodola
on 17 Aug 2012 at 6:14
Original issue reported on code.google.com by
fdv...@gmail.com
on 14 Jun 2011 at 8:20