Skip to contentSkip to conversation

Changing argv[0] under Linux.

DISCUSSION Jon Burgess 2 participants 2 messages Jan 16, 2003

lore
Share & tools
lore
#0 lore raw
Quoted 3 lines

Any suggestion on how to get the binary name from the core image?

How about:

exec("/proc/self/exe", ...)

I found something like this handy when writing an self extracting compressed executable a while ago.

Jon

#1 lore raw

Hi Jon :)

Quoted 1 line

exec("/proc/self/exe", ...)

That's good, but I would like to avoid to mount procfs: what if
the mount point '/proc' doesn't exist? If you create it, you must mount root rw and remount ro again, not a very good idea if it haven't been fscked yet, for example. You can mount under /tmp, if it exists at all, but that simply displaces the problem. What if /proc/self/exe is not part form procfs, but from some evil user ;))

Thanks a lot for your answer :)

Raúl