Re: [PATCH] provide a workaround if program_invocation_short_name is missing

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Jan 18, 2011 at 12:14:52AM +0100, Karel Zak wrote:
> On Mon, Jan 17, 2011 at 09:01:02PM +0100, Fabian Groffen wrote:
> > +#ifndef HAVE_PROGRAM_INVOCATION_SHORT_NAME
> > +#include <string.h>
> > +#define program_invocation_short_name prog_inv_sh_nm_from_file(__FILE__)
> > +static char prog_inv_sh_nm_buf[256];
> > +static inline char *
> > +prog_inv_sh_nm_from_file(char *f) {
> > +	char *t;
> > +
> > +	if ((t = strrchr(f, '/')) != NULL) {
> > +		t++;
> > +	} else {
> > +		t = f;
> > +	}
> > +
> > +	strncpy(prog_inv_sh_nm_buf, t, sizeof(prog_inv_sh_nm_buf) - 1);
> > +	prog_inv_sh_nm_buf[sizeof(prog_inv_sh_nm_buf) - 1] = '\0';
> > +
> > +	if ((t = strrchr(prog_inv_sh_nm_buf, '.')) != NULL)
> > +		*t = '\0';
> > +
> > +	return prog_inv_sh_nm_buf;
> > +}
> > +#endif
> > +
> 
>  on Linux it's possible to use the /proc filesystem to get process
>  name, wouldn't it be possible anything similar on Solaris?

 or use __progname or getexecname() or so...

    Karel

-- 
 Karel Zak  <kzak@xxxxxxxxxx>
 http://karelzak.blogspot.com
--
To unsubscribe from this list: send the line "unsubscribe util-linux" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux