From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/2971 Path: news.gmane.org!not-for-mail From: Szabolcs Nagy Newsgroups: gmane.linux.lib.musl.general Subject: Re: program_invocation_name Date: Sun, 24 Mar 2013 03:49:54 +0100 Message-ID: <20130324024954.GP19010@port70.net> References: <20130324001618.GA4844@brightrain.aerifal.cx> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1364093405 24054 80.91.229.3 (24 Mar 2013 02:50:05 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 24 Mar 2013 02:50:05 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-2972-gllmg-musl=m.gmane.org@lists.openwall.com Sun Mar 24 03:50:31 2013 Return-path: Envelope-to: gllmg-musl@plane.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1UJb0w-0005eR-4F for gllmg-musl@plane.gmane.org; Sun, 24 Mar 2013 03:50:30 +0100 Original-Received: (qmail 28087 invoked by uid 550); 24 Mar 2013 02:50:06 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 28079 invoked from network); 24 Mar 2013 02:50:05 -0000 Content-Disposition: inline In-Reply-To: <20130324001618.GA4844@brightrain.aerifal.cx> User-Agent: Mutt/1.5.21 (2010-09-15) Xref: news.gmane.org gmane.linux.lib.musl.general:2971 Archived-At: * Rich Felker [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