From: Guillem Jover Date: Mon, 17 Apr 2023 22:44:49 +0000 (+0200) Subject: Port getprogname() to AIX X-Git-Tag: 0.11.8~26 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9fa06763a1afe0946a3a20e5bbdba72885cbade5;p=thirdparty%2Flibbsd.git Port getprogname() to AIX Get the program name from the COMM field from the proc filesystem. We could use instead the information from the psinfo binary file under /proc, but that seems to have a shorter string limit. --- diff --git a/src/progname.c b/src/progname.c index b62ecd4..56d91ec 100644 --- a/src/progname.c +++ b/src/progname.c @@ -62,6 +62,14 @@ getprogname(void) /* getexecname(3) returns an absolute pathname, normalize it. */ if (__progname == NULL) setprogname(getexecname()); +#elif defined(_AIX) + if (__progname == NULL) { + struct procentry64 procs; + pid_t pid = getpid (); + + if (getprocs64(&procs, sizeof procs, NULL, 0, &pid, 1) > 0) + __progname = strdup(procs.pi_comm); + } #elif defined(_WIN32) if (__progname == NULL) { WCHAR *wpath = NULL;