Linked by Jussi Pakkanen on Tue 17th Apr 2007 18:20 UTC
Thread beginning with comment 231714
To read all comments associated with this story, please click here.
To read all comments associated with this story, please click here.





Member since:
2006-09-30
Indeed that seems really insane.
That could be more portable (hmmm) than using /proc.
In BeOS the loaded images are walkable with get_next_image_info(), the first one being the exe, and it contains the full path to it. I use that trick quite often.
http://www.beunited.org/bebook/The%20Kernel%20Kit/Images.ht...
Also, but I consider this a bug (also because get_next_image_info() could do it) argv[0] is overwritten in BeOS by the full path to the exe, to allow the BApplication object to find its resources.
So at the question where am I, you could just say dirname(argv[0]). But of course that can't work in Unix because they use argv[0] to stuff ugly things like "-sh" for a login shell.
Hmm anyone ever thought about trying to run lsof|grep something to find the path for the mmap()ed lib ?