finding the full path of a process binary using /proc
807578Aug 3 2004 — edited Aug 20 2004Hello,
I have an application where I need to monitor whether a certain other process is running. I'm using the /proc filesystem and an ioctl call - namely, PIOCPSINFO - to fetch process information into a prpsinfo_t, then use either the pr_fname field for the base name of the process executable or pr_psargs for the full launch command line - the first argument being the executable name. However, I see that if I launch something like "man chmod" in the shell, the pr_psargs for that process is "man chmod", not "/usr/bin/man chmod", thus making it hard to distinguish between binaries which have the same base name, but can be run from different locations (e.g. /usr/ccs/bin/make and /usr/local/bin/make). Is there some way to find out the environment (actually, the PATH variable) that a process has been run with? I see there's an 'uintptr_t pr_envp' in pr_psinfo_t that is supposed to be the "address of initial environment vector". How can I use that?