site_archiver@lists.apple.com Delivered-To: darwin-kernel@lists.apple.com The following code gives the current process name. struct proc *p = current_proc(); p->p_comm // contains current process name On Tiger, it is working fine, but on leopard, p_comm is empty. -- Terry _______________________________________________ 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... On Mar 20, 2008, at 2:34 AM, Quinn wrote: At 14:38 +0530 20/3/08, Praveen Kumar wrote: Please let me know if there are alternate ways to get the current process name. (struct proc) is private, and has been since 10.4. You should /not/ be trying to access fields within it. In fact, I'm confused as to how this even compiles! Fortunately, there is a much better way to do this. Check out proc_name defined in <sys/proc.h> in the Kernel framework. Also, proc_self (from the same header) is a more modern way to get the current process. If you switch to that, please note that it gives you a reference to the current process that you then have to release using proc_rele. There is also the KPI function proc_selfname(), which returns the name of the current process in a string buffer supplied by the caller. Note that Mike Smith's point about no using the name to make any decisions, particularly security decisions, is a good one. This email sent to site_archiver@lists.apple.com