How to get process name from process id in all Unix platforms?

Hi,

i need to find the process name using the process id in C. This has to be done in HP, AIX, Solaris & Linux??

How can this be done? Is there any common solution to all platforms?

On linux i have heard that /proc/<pid>/cmdline can be used. Is there a structure available to read this?

Please let me know.

Thanks,
molu

See this post for more details - PS Command Field

There is an example provided in the external link in the above post. That should help you.

Isnt there any struct available in linux that has the /proc info?

I found prpsinfo struct for SOlaris

I have found solns for most platforms --
Solaris - read psinfo struc (refer proc man page)
AIX- Use getprocs() func
HP - Use pstat_getproc func.