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

Only the pid of the processes are returned in Mac OS X 10.7 Lion (preview 4) #173

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

Comments

@giampaolo
Copy link
Owner

From fdv...@gmail.com on June 14, 2011 10:20:08

What steps will reproduce the problem?  
1. Execute the following code:
import psutil

for un in psutil.process_iter():
  try:
    print un
  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.21
- python 2.7 

On what operating system? Is it 32bit or 64bit version?  
Mac OS X 10.7 Lion (preview 4) 64 bits 

Please provide any additional information below.  
If you, for example, replace in the code above "print un" with "print un.name", 
you will only get: kernel_task

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

@giampaolo giampaolo self-assigned this May 23, 2014
@giampaolo
Copy link
Owner Author

From g.rodola on June 14, 2011 01:24:36

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?

@giampaolo
Copy link
Owner Author

From fdv...@gmail.com on June 14, 2011 01:39:40

- 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"

@giampaolo
Copy link
Owner Author

From g.rodola on June 14, 2011 01:55:23

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.

Owner: jlo...@gmail.com
Labels: OpSys-OSX Usability

@giampaolo
Copy link
Owner Author

From jlo...@gmail.com on June 14, 2011 04:40:23

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

@giampaolo
Copy link
Owner Author

From fdv...@gmail.com on June 14, 2011 06:50:17

Yes, I executed exactly "p = psutil.Process(os.getpid())". As far as I know, 
10.7 has got changes in the permissions system.

@giampaolo
Copy link
Owner Author

From turbina...@gmail.com on September 18, 2011 11:45:38

I get this error on 10.6 as well, both as root and as a normal user.

@giampaolo
Copy link
Owner Author

From jlo...@gmail.com on September 18, 2011 11:53:55

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.

@giampaolo
Copy link
Owner Author

From ske...@googlemail.com on April 05, 2012 07:26:41

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.

@giampaolo
Copy link
Owner Author

From g.rodola on August 17, 2012 11:14:08

This should have been fixed in issue 297 .
Closing it out.

Status: Duplicate
Mergedinto: 297

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