Re: [libgpiod,v2 1/2] tools: use getprogname() when available to remove dependency on glibc

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

 



On Sat, Feb 25, 2023 at 4:12 AM Benjamin Li <benl@xxxxxxxxxxxx> wrote:
>
> Platforms like Bionic libc don't have program_invocation_[short_]name,
> which is a GNU extension. Use getprogname() from stdlib.h, another
> widely agreed extension, when it's available.
>
> It seemed a little heavyweight to add gnulib to this project's autotools
> set-up just for making one function portable, so I've just added the
> portabilty shim to tools-common.c for the moment.
>
> Signed-off-by: Benjamin Li <benl@xxxxxxxxxxxx>
> ---

This is only relevant for gpio-tools so maybe instead of relying on
either a GNU or BSD extension, let's just ditch both (and the checking
infrastructure) and introduce our own local helpers:

void set_prog_name(const char *name);
const char *get_prog_name(void);
const char *get_prog_shortname(void);

And call set_prog_name(argv[0]) at the start of each program?
Alternatively we can just use prctl() like libgpiosim does for tests
but then we'd lose the potential info about the executable path.

I'm thinking this is better than relying on extensions as I've already
had to stop using twalk_r() due to it being a GNU extension not
provided by musl (not by bionic as I can see).

Bart




[Index of Archives]     [Linux SPI]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux