Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Sun, 24 Mar 2013 03:49:54 +0100
From: Szabolcs Nagy <nsz@...t70.net>
To: musl@...ts.openwall.com
Subject: Re: program_invocation_name

* Rich Felker <dalias@...ifal.cx> [2013-03-23 20:16:18 -0400]:
> ??? Variable: char * program_invocation_name
> ??? Variable: char * program_invocation_short_name

these look ridiculous..

> But my understanding is that these descriptions are false, and that
> program_invocation_name is just a pointer to the same storage as
> argv[0], and program_invocation_short_name points to the tail of
> argv[0]. In this case, modifications to argv[0] would be reflected
> through these pointers. Is that correct and reasonable? The

yes, that's what glibc does so these
can be gibberish if argv[0] is changed

> If we do add program_invocation_short_name, what should the size/speed
> tradeoff be? I really don't want to make strrchr a mandatory part of
> the startup code; would a trivial loop to do the job suffice?
> 
> for (s=t=argv[0]; *t; t++) if (*t=='/') s=t+1;

yes that makes sense assuming argv[0]!=0

> P.S. If we do add these, we could certainly add the BSD names too as
> aliases.

bsd only has the short version (__progname)
and openbsd does the copy (into a NAME_MAX sized buffer)
while freebsd does not

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.