libdpkg: Add support for AIX to dpkg_get_progname()

On AIX we need to use getprocs64() to fetch the current program name.

Changelog: porting
This commit is contained in:
Guillem Jover
2021-05-01 23:58:00 +02:00
parent 6a9d238b10
commit 679760fd15
2 changed files with 13 additions and 0 deletions

View File

@ -192,6 +192,7 @@ AC_CHECK_FUNCS([\
isascii \
setsid \
getdtablesize \
getprocs64 \
getprogname \
getexecname \
lutimes \

View File

@ -21,6 +21,12 @@
#include <config.h>
#include <compat.h>
#ifdef HAVE_GETPROCS64
#include <sys/types.h>
#include <string.h>
#include <unistd.h>
#include <procinfo.h>
#endif
#include <errno.h>
#include <stdlib.h>
@ -70,6 +76,12 @@ dpkg_get_progname(void)
#elif defined(HAVE_GETEXECNAME)
/* getexecname(3) returns an absolute path, normalize it. */
dpkg_set_progname(getexecname());
#elif defined(HAVE_GETPROCS64)
struct progentry64 pe;
pid_t pid = getpid();
if (getprocs64(&pe, sizeof(pe), NULL, 0, &pid, 1) >= 0)
progname = strdup(pe.pi_comm);
#endif
}