Fallback for getting program name breaks pkill
Hi,
Android is an example of a platform that does not have program_invocation_short_name
or getexecname
, but that does have __progname
. Compiling procps for android currently (without manually setting HAVE__PROGNAME) mean that we end up with getting the program name from prog_inv_sh_nm_from_file(__FILE__, 1)
, from the code in c.h.
This definition breaks pkill (and maybe others), since pkill's source is part of pgrep.c, so when we use prog_inv_sh_nm_from_file(__FILE__, 1)
running pkill actually executes pgrep.
I do not have a good suggestion for what to do instead. Using argv[0]
somehow could work, but it requires changing how various messages are printed as well, since argv[0]
is not defined everywhere. For the record I tried compiling with:
# else
# define program_invocation_short_name basename(argv[0])
# endif
But it does not compile due to program_invocation_short_name
being used in PROCPS_NG_VERSION
, the usage message and some other places:
../free.c:74:30: error: use of undeclared identifier 'argv'
_(" %s [options]\n"), program_invocation_short_name);
^
../include/c.h:86:12: note: expanded from macro 'program_invocation_short_name'
basename(argv[0])
^