Finding process path
Hi,
I am having difficulty in finding process path. On Linux, I was doing it using readlink("/proc/self/exe", szAppPath, MAX_PATH); or sprintf(szStr, "/proc/%d/exe", nProcID); readlink(szStr, szAppPath, MAX_PATH); But on Solaris 9 x86 platform, this function fails, as there is no "exe" entry in /proc/self. Is there any other way to find the process path?. Praj. |
Here's one way:
Code:
pmap <process-id> | head -2 | tail -1 | nawk '{print $4}' |
:confused:
I want it programmatically. |
Well, I did it programmatically ... with shell and a piece of awk ;)
If by programmatically you mean you want it in C, what about: Code:
#include <stdio.h> |
Thanks a lot.
But it prints some brackets [ I am working on Sun Solaris 9 - x86 Platform Edition gcc version 3.3.2 GNU ld version 2.11.2 GNU Make 3.80 Am I on the wrong track. |
Here's a slightly better version that should work for you:
Code:
#include <stdio.h> |
All times are GMT -5. The time now is 11:27 AM. |