On HP-UX (hppa 64-bit), the test-xalloc-die.sh test fails: *** - Thu Oct 11 15:47:41 2018 --- err2 Thu Oct 11 15:55:06 2018 *************** *** 1 **** ! test-xalloc-die: memory exhausted --- 1 ---- ! test-xalloc-di: memory exhausted FAIL test-xalloc-die.sh (exit status: 1)
The reason is a truncation of the program name to 14 characters. This can be avoided in some cases. The command can be up to 63 characters and may contain the program name. 2018-10-11 Bruno Haible <br...@clisp.org> getprogname: Work around program name truncation when possible. * lib/getprogname.c (getprogname) [HP-UX]: When pst_ucomm is truncated, possibly use pst_cmd instead. diff --git a/lib/getprogname.c b/lib/getprogname.c index 58625de..4f97df4 100644 --- a/lib/getprogname.c +++ b/lib/getprogname.c @@ -110,9 +110,33 @@ getprogname (void) 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 (pstat_getproc (&status, sizeof status, 0, pid) > 0) + { + if (strlen (status.pst_ucomm) < PST_UCOMMLEN - 1) + p = status.pst_ucomm; + else + { + /* status.pst_ucomm is truncated to length PST_UCOMMLEN - 1. + Look at status.pst_cmd instead. */ + char *space = strchr (status.pst_cmd, ' '); + if (space != NULL) + *space = '\0'; + p = strrchr (status.pst_cmd, '/'); + if (p != NULL) + p++; + else + p = status.pst_cmd; + if (strlen (p) > PST_UCOMMLEN - 1 + && memcmp (p, status.pst_ucomm, PST_UCOMMLEN - 1) == 0) + /* p is less truncated than status.pst_ucomm. */ + ; + else + p = status.pst_ucomm; + } + p = strdup (p); + } + else + p = NULL; if (!p) p = "?"; }