Final Suggestion (Re: suggested bsd-setproctitle.c)
stevesk at sweden.hp.com
Wed Nov 8 20:51:16 EST 2000
On Tue, 7 Nov 2000, Ben Lindstrom wrote:
: May I suggest the attached patch. Since It's been compiled against NeXT
: it pretty much ensure that all __progname is setup right (since NeXT
: supports it).
: I would perfer using basename() over strrchar() and NULL check. Even it
: it required me to snag basename() from the OpenBSD tree. (Which I was
: happy to see compiled without any changes!! =)
I was more concerned with cleaning up ifdef bloat vs. fixing the
hardcoded names, but I agree it makes sense to fix that as well.
I don't see a need to necessarily malloc new space for a copy.
i386/crt0.c does this:
if ((ap = argv))
if ((__progname = _strrchr(ap, '/')) == NULL)
__progname = ap;
If you look at Kerberos or afs warnerr.c you see:
const char *__progname;
if(argv0 == NULL)
p = strrchr(argv0, '/');
if(p == NULL)
p = argv0;
__progname = p;
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);
More information about the openssh-unix-dev