Re: Process name from PID inside kernel?
Re: Process name from PID inside kernel?
- Subject: Re: Process name from PID inside kernel?
- From: Quinn <email@hidden>
- Date: Tue, 31 Oct 2006 09:51:50 +0000
At 0:52 -0800 31/10/06, Rick Mann wrote:
I've been looking through the KPI, and I'm not having a lot of luck.
This is the subject of a long-standing enhancement request
<rdar://problem/4488658>. You're unlikely to get this as a KPI,
however. In general I recommend that you bounce this sort of
activity out to user space.
I found a hacked way to get the PID inside my kext, which is
fragile, but works for now. Now I'd like to get the name of that
process. I've actually got access to the executable's vnode, but I
can't figure out how to get the filename from the vnode from within
the kernel. This would be sufficient for now.
If you have the executable's vnode (which is a feat in itself), you
can get the path using vn_getpath.
From here it all depends on what you mean by "process name". Mac OS
X has at least two "process name" concepts.
o At the BSD level, there is the name shown by "ps". This is simply
the last component of the executable's path.
o At the GUI framework level, there is the name shown in the menu bar
(and by the Dock). This is only available via Process Manager (and
stuff, like NSWorkspace, layered on top of the Process Manager). If
you have a PID, you can map it to a PSN (using GetProcessForPID) and
then get the name from the PSN (using CopyProcessName). The gotcha
is the Process Manager is part of ApplicationServices layer, so you
can only call it from within a GUI context. The implications of this
are covered by DTS Technote 2083 "Daemons and Agents".
<http://developer.apple.com/technotes/tn2005/tn2083.html>
There is another long-standing enhancement request for pushing
Process Manager (well, an API like Process Manager) down to the
CoreServices level.
S+E
--
Quinn "The Eskimo!" <http://www.apple.com/developer/>
Apple Developer Relations, Developer Technical Support, Core OS/Hardware
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-kernel mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden