--- lib/getprogname.c.save	2016-10-26 14:14:12 +0000
+++ lib/getprogname.c	2016-10-26 19:23:52 +0000
@@ -28,6 +28,13 @@
 # include <string.h>
 #endif
 
+#ifdef __hpux
+# include <unistd.h>
+# include <sys/param.h>
+# include <sys/pstat.h>
+# include <string.h>
+#endif
+
 #include "dirname.h"
 
 #ifndef HAVE_GETPROGNAME
@@ -73,6 +80,21 @@
            : NULL);
       if (!p)
         p = "?";
+    }
+  return p;
+# elif __hpux
+  static char *p;
+  static int first = 1;
+  if (first)
+    {
+      first = 0;
+      pid_t pid = getpid ();
+      struct pst_status status;
+      p = (0 < pstat_getproc (&status, sizeof status, 0, pid)
+           ? strdup (status.pst_ucomm)
+           : NULL);
+      if (!p)
+        p = "?";
     }
   return p;
 # else
--- gnulib-tests/test-getprogname.c.save	2016-10-26 19:24:46 +0000
+++ gnulib-tests/test-getprogname.c	2016-10-26 19:28:13 +0000
@@ -20,7 +20,11 @@
 #include <string.h>
 #include <assert.h>
 
+#ifdef __hpux
+#define STREQ(a, b) (strncmp (a, b, 14) == 0)
+#else
 #define STREQ(a, b) (strcmp (a, b) == 0)
+#endif
 
 int
 main (void)
