site_archiver@lists.apple.com Delivered-To: darwin-kernel@lists.apple.com <http://developer.apple.com/technotes/tn2005/tn2083.html> 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 (Darwin-kernel@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-kernel/site_archiver%40lists.a... 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". There is another long-standing enhancement request for pushing Process Manager (well, an API like Process Manager) down to the CoreServices level. This email sent to site_archiver@lists.apple.com