how to get process' full path name + executable

how to get process' full path name + executable

Post by thai4.. » Sat, 20 Nov 1999 04:00:00



hello,

i'm new to this group. sorry if this question has been asked
way too many times before. i've searched thru old postings
but didn't find anything.

anyway, i'd like to be able to do what "/usr/proc/bin/pmap" does.
ie: get the full path name of a process.

i'm able to get the executable name via /proc/<pid>/psinfo as
well as /proc/<pid>/auxv (and /proc/<pid>/as). but i really
need the full path name.

does anybody know where i can find the source code for pmap?

thanks in advance.

ps: i'm running solaris 7.

Sent via Deja.com http://www.deja.com/
Before you buy.

 
 
 

how to get process' full path name + executable

Post by Roger A. Faulkn » Sun, 21 Nov 1999 04:00:00



>hello,

>i'm new to this group. sorry if this question has been asked
>way too many times before. i've searched thru old postings
>but didn't find anything.

>anyway, i'd like to be able to do what "/usr/proc/bin/pmap" does.
>ie: get the full path name of a process.

>i'm able to get the executable name via /proc/<pid>/psinfo as
>well as /proc/<pid>/auxv (and /proc/<pid>/as). but i really
>need the full path name.

I assume you have used the address in the AT_SUN_EXECNAME aux
vector entry and then have read from /proc/<pid>/as at that offset
to get the executable's pathname.

This gives you a full pathname in most cases.  If not, it is because
the command was executed using a relative pathname (e.g., "./foo ...").
In this case, if the process has not changed its current working
directory, you can use chdir("/proc/<pid>/cwd") and use getcwd(3C)
to get the path to the current directory of the process.  Concatenating
them yields the full pathname.

That is how pmap does it.

If the process is statically linked, then you are totally out of luck.

Quote:>does anybody know where i can find the source code for pmap?

Sorry, you can't have it unless you have a Solaris source license.

Roger Faulkner