suggested bsd-setproctitle.c

David Terrell dbt at
Wed Nov 8 12:49:57 EST 2000

On Tue, Nov 07, 2000 at 05:16:22PM -0800, David Terrell wrote:
> On Mon, Nov 06, 2000 at 06:52:02AM +0100, Kevin Steves wrote:
> > That should work.  But it seems this __progname issue could be cleaned
> > up by defining the variable in main() files if needed:
> > 
> > #ifndef HAVE___PROGNAME
> > const char *__progname = "foo";
> > #endif
> > 
> > then declaring it (no ifdefs) if it's referenced:
> > 
> > extern const char *__progname;
> > 
> > This gets us closer to OpenBSD's tree with fewer ifdefs.
> > 
> > I'll do this patch unless someone points out what it will break :)
> It breaks the actual functionality of __progname, which is roughly
> equivelent to basename(argv[0]).

To make a more useful suggestion:

char *__progname;

then in main()
	__progname = xstrdup(basename(argv[0]);

It's not a const, though.  Tread carefully.  Make sure not to pass
it to printf()-like functions as a format string, especially in
ssh, where it could be setuid.  etc.

Dave, who can write up a pretty patch if desired, I don't have the portable
      source tree around right now.

David Terrell   | "To increase the hype, I'm gonna release a bunch
Nebcorp PM      | of BLT variants (NetBLT, FreeBLT, BLT386, etc)
dbt at    | and create artificial rivalries." |  - Brian Sweltand (

More information about the openssh-unix-dev mailing list