get_executable_name (3) - Linux Man Pages
get_executable_name: Obtains the full path to the current executable. Allegro game programming library.
NAMEget_executable_name - Obtains the full path to the current executable. Allegro game programming library.
DESCRIPTIONFills `buf' with the full path to the current executable, writing at most `size' bytes. This generally comes from `argv' but on Unix systems it tries to get the information from the `/proc' filesystem first, searching the directories specified in `$PATH' if necessary. If this fails too, it tries to find the executable name from the output of the `ps' command, using `argv' only as a last resort if all other options fail. Example:
char name; ... get_executable_name(name, sizeof(name)); allegro_message("Running `%s'\n", name);