+2016-09-21 Jim Meyering <meyering@fb.com>
+
+ getprogname: port to AIX
+ * lib/getprogname.c (getprogname) [_AIX]: Use getpid, getprocs64
+ and strdup to obtain a short program name string. Using code from
+ Bruno Haible and an idea from Bastien ROUCARIÈS, in
+ https://lists.gnu.org/archive/html/bug-gnulib/2010-12/msg00249.html
+ Assaf Gordon reported that this new file would fail to compile on
+ AIX-7.1 32bit.
+
2016-09-16 Paul Eggert <eggert@cs.ucla.edu>
extensions: fix typo in comment
#include <errno.h> /* get program_invocation_name declaration */
#include <stdlib.h> /* get __argv declaration */
+#ifdef _AIX
+# include <unistd.h>
+# include <procinfo.h>
+# include <string.h>
+#endif
+
#include "dirname.h"
#ifndef HAVE_GETPROGNAME
# elif HAVE_DECL___ARGV
const char *p = __argv && __argv[0] ? __argv[0] : "?";
return last_component (p);
+# elif _AIX
+ /* Idea by Bastien ROUCARIÈS <address@hidden>,
+ http://lists.gnu.org/archive/html/bug-gnulib/2010-12/msg00095.html
+ Reference: http://
+ ibm.biz/knowctr#ssw_aix_53/com.ibm.aix.basetechref/doc/basetrf1/getprocs.htm
+ */
+ static char *p;
+ static int first = 1;
+ if (first)
+ {
+ first = 0;
+ pid_t pid = getpid ();
+ struct procentry64 procs;
+ p = (0 < getprocs64 (&procs, sizeof procs, NULL, 0, &pid, 1)
+ ? strdup (procs.pi_comm)
+ : NULL);
+ if (!p)
+ p = "?";
+ }
+ return p;
# else
# error "getprogname module not ported to this OS"
# endif