LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   what is the call to determine the app you are running in (https://www.linuxquestions.org/questions/programming-9/what-is-the-call-to-determine-the-app-you-are-running-in-401636/)

erwinfletch 01-10-2006 10:24 AM

what is the call to determine the app you are running in
 
Hi-

I need the cpp call that will tell me the full path to the app I'm running in. For example, I'm running in a loaded library for either mozilla or firefox, but would like to know the full path to the executable

/usr/bin/firefox
/usr/bin/mozilla
/usr/local/firefox1_5

etc...

(For windows programmers, it would be the Linux version of GetModuleFileNameW)

Thanks!

bigearsbilly 01-10-2006 10:31 AM

same as C isn't it?
main(int argc, char** argv)

argc is no of args

argv[0] is the pathname.
argv[1] is arg 1 ... etc

erwinfletch 01-10-2006 10:46 AM

Hi- Thanks for the reply...

That would be true if I had a main... unfortunately I don't since I'm running in a .so. I'm looking for a function call that will give me the same information. I've now found the Mac version for the call(GetFilePathFromFSRef) but still no linux. I'm assuming it will be the same for all UNIX flavors, but maybe not.

Thanks!

ask.jackal 01-11-2006 09:52 AM

probably use getuid() and read the info from /proc/$PID/cmdline and /proc/$PID/environ.Assumes a proc file system for u.


All times are GMT -5. The time now is 03:43 AM.