Linked by Jussi Pakkanen on Tue 17th Apr 2007 18:20 UTC
Editorial Let me begin by telling you a little story. Some time ago I needed to run a script at work once a day. We had tons of machines ranging from big Unix servers to Linux desktops. Due to various reasons the script could only be run on a desktop machine. However using cron was disabled on desktops. All other machines allowed cron.
Thread beginning with comment 231714
To read all comments associated with this story, please click here.
where am I...
by mmu_man on Tue 17th Apr 2007 22:08 UTC
mmu_man
Member since:
2006-09-30

Indeed that seems really insane.
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 ? ;) That could be more portable (hmmm) than using /proc.