argv array
argv[0] is a parameter like any other: it can be an arbitrary ending string with NUL bytes. This may be an empty string. This is what the startup process wants.
By default, the shell with the setting argv[0] used to indicate the program: the name found in $PATH , relative or absolute path. It can be a symbolic link or a regular file.
To invoke a program with some other value, with zsh (dunno with other shells) use:
ARGV0 = whatever_you_want some_program arguments
If you really need a path to the executable, you cannot use the command line on Unix.
Linux only
On Linux: /proc/self/exe is a symbolic link to an executable file.
You can readlink it. You can also directly stat or open .
Rename and soft link
A normal soft link is a dumb line and does not know what is happening with its purpose (if it exists at all). But the soft link /proc/self/exe is magic.
In case of renaming, soft-but-magic-link will follow the renaming. If there are several hard links, this will follow the name of the specific hard link that was used. (So different hard links to the same file are not exactly equivalent under Linux.)
If this hard link is disconnected, I think that " (deleted)" added to the value of the symlink. Note that this is a valid file name, so another unrelated file may have that name.
In any case, a symbolic link is a hard link to a file , so you can directly stat or open .
I do not think that you can count on anything in the network file system if the binary is renamed or detached on a different system than the one where the executable is running.
Security questions
When your program uses the special /proc/self/exe , the file used to run your program will be unlink ed or rename d. This should be taken seriously if the program has the privilege (SUID or Set Capabilities): even if the user does not have write access to the source binary “Set Something”, he can make a hard link to it if he has write access to the directory in that same file system, so it can change the name if a privileged binary is running.
By the time you readlink , the return value may refer to another file. (Of course, there is always an inevitable race condition with an open readlink result.)
As usual, NFS does not provide all the same guarantees as local file systems.