Final Suggestion (Re: suggested bsd-setproctitle.c)

Ben Lindstrom mouring at pconline.com
Thu Nov 9 01:07:18 EST 2000



On Wed, 8 Nov 2000, Kevin Steves wrote:

[..]
> #ifndef HAVE___PROGNAME
> const char *__progname;
> #endif
> 
> void
> set_progname(char *argv0)
> {
> #ifndef HAVE___PROGNAME
>     char *p;
>     if(argv0 == NULL)
> 	return;
>     p = strrchr(argv0, '/');
>     if(p == NULL)
> 	p = argv0;
>     else
> 	p++;
>     __progname = p;
> #endif
> }
> 
> I'd prefer adding a set_progname() modified to return progname, and
> using it vs. importing bsd-basename and mallocing space.
> 
> So in main() we'd have:
> 
> __progname = set_progname(argv[0]);
> 
For as much as I dislike functions that modify global variables. I think
the orignal set_progname() may be better then changing it to return the
progname.  I don't believe we should be setting __progname unless it's not
set originally.

Unless you plan on moving the #ifndef .. #endif to around the call in
main().

- Ben






More information about the openssh-unix-dev mailing list