Proposal: Add getFullProgName

Bardur Arantsson spam at
Wed Jun 13 05:08:06 CEST 2012

On 06/13/2012 03:21 AM, Johan Tibell wrote:
> On Tue, Jun 12, 2012 at 5:59 PM, Thomas Schilling
> <nominolo at> wrote:
>> I don't think this is guaranteed to work.  See top answer here [1]
>> (which cites the standard).  Also, note that the man page for exec and
>> friends notes that the first argument *by convention* is the name of
>> the executable.
> That's right. argv[0] could be anything, including "my hair is on
> fire". In this sense getFullProgName is as incorrect/correct as
> getProgName. In practice it will be the program name and then
> getFullProgName can be used to do useful work, other than printing the
> program base name, unlike getProgName. :)

Not saying it's not an improvement over getProgName (definitely is), but
if the intent is to provide the most accurate name of the executable
which is running, then...

You should probably read the /proc/self/exe symlink on Linux. (Of course
/proc may not be mounted so you'll need a fallback in any case...)

I believe FreeBSD and Solaris have similar methods using /proc.

On Win32 it seems that using GetModuleFileName with a NULL first
parameter is the way to go:


More information about the Libraries mailing list