TIL you can get the path to the current executable with getauxval(AT_EXECFN) on Linux, no messing with /proc necessary. It's a separate block of memory filled by the kernel, not argv[0] or anything.
-
-
Replying to @whitequark
As I understand it, AT_EXECFN is the exact string that was passed to SYS_execve, so it could be relative to . at the time of exec, could no longer be valid due to changes to fs, etc.
1 reply 0 retweets 3 likes -
Replying to @RichFelker @whitequark
Also if the program was invoked via a symlink, it will be the pathname of the symlink, not the file the symlink resolved to.
1 reply 0 retweets 2 likes
Replying to @RichFelker @whitequark
In particular if you re-exec'd /proc/self/exe or if fexecve exec'd /proc/self/fd/%d, then AT_EXECFN is utterly meaningless.
9:43 AM - 10 Jan 2018
0 replies
0 retweets
3 likes
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.