Subject: Re: __progname (was Re: audit of syslog(3) usage...)
To: der Mouse <mouse@Rodents.Montreal.QC.CA>
From: Luke Mewburn <>
List: tech-userlevel
Date: 01/22/2001 12:43:13
On Sun, Jan 21, 2001 at 08:02:07PM -0500, der Mouse wrote:
> > 	- On a tangental point, if we get around to replacing
> > 		const char *__progname
> > 	  with something more portable like: 
> > 		const char *getprogname(const char *argv0)
> I would hope not.  Speaking with my application-author hat on, one of
> the biggest wins of __progname is that it *doesn't* require me to
> preserve argv[0] from main down to the usage point (which usually means
> either a shared global or an extra argument down through the call
> chain, the latter sometimes bordering on impossible).  It's nice enough
> that I even went to the trouble to produce a localized crt0 with
> __progname on the SunOS machines I have occasion to build code on.

So declare your own global variable and set it in main().

__progname is just another item of unportability that you have to work
around to get NetBSD programs running on other platforms.  Hacking crt0
is not generally an option for most people.