Thanks, normally we don't care about IRIX any more but it seems you're still
using it here so why not? I installed the attached into gnulib. I can't easily
test this on IRIX so please test this at your convenience.
From 7d75021d82318d9a297becf18d7a1f7394f2776e Mon Sep 17 00:00:00 2001
From: Paul Eggert <egg...@cs.ucla.edu>
Date: Fri, 6 Jan 2017 16:14:21 -0800
Subject: [PATCH] getprogname: port to IRIX
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
* lib/getprogname.c (getprogname): Port to IRIX.
Based on an idea by Bastien Roucariès at:
http://lists.gnu.org/archive/html/bug-gnulib/2010-12/msg00096.html
via code from Bruno Haible at:
https://lists.gnu.org/archive/html/bug-gnulib/2010-12/msg00249.html
---
ChangeLog | 7 +++++++
lib/getprogname.c | 31 +++++++++++++++++++++++++++++++
2 files changed, 38 insertions(+)
diff --git a/ChangeLog b/ChangeLog
index 25db030..d51ed84 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
2017-01-06 Paul Eggert <egg...@cs.ucla.edu>
+ getprogname: port to IRIX
+ * lib/getprogname.c (getprogname): Port to IRIX.
+ Based on an idea by Bastien Roucariès at:
+ http://lists.gnu.org/archive/html/bug-gnulib/2010-12/msg00096.html
+ via code from Bruno Haible at:
+ https://lists.gnu.org/archive/html/bug-gnulib/2010-12/msg00249.html
+
localename-tests: port to NetBSD 7
Problem reported by Nelson H. F. Beebe.
* tests/test-localename.c:
diff --git a/lib/getprogname.c b/lib/getprogname.c
index fb6d8b8..729f01e 100644
--- a/lib/getprogname.c
+++ b/lib/getprogname.c
@@ -43,6 +43,14 @@
# include <string.h>
#endif
+#ifdef __sgi
+# include <string.h>
+# include <unistd.h>
+# include <stdio.h>
+# include <fcntl.h>
+# include <sys/procfs.h>
+#endif
+
#include "dirname.h"
#ifndef HAVE_GETPROGNAME /* not Mac OS X, FreeBSD, NetBSD, OpenBSD >= 5.4, Cygwin */
@@ -143,6 +151,29 @@ getprogname (void)
free (buf.ps_pathptr);
}
return p;
+# elif defined __sgi /* IRIX */
+ char filename[50];
+ int fd;
+
+ sprintf (filename, "/proc/pinfo/%d", (int) getpid ());
+ fd = open (filename, O_RDONLY);
+ if (0 <= fd)
+ {
+ prpsinfo_t buf;
+ int ioctl_ok = 0 <= ioctl (fd, PIOCPSINFO, &buf);
+ close (fd);
+ if (ioctl_ok)
+ {
+ char *name = buf.pr_fname;
+ char *namesize = sizeof buf.pr_fname;
+ char *namenul = memchr (name, '\0', namesize);
+ size_t namelen = namenul ? namenul - name : namesize;
+ char *namecopy = malloc (namelen + 1);
+ namecopy[namelen] = 0;
+ return memcpy (namecopy, name, namelen);
+ }
+ }
+ return NULL;
# else
# error "getprogname module not ported to this OS"
# endif
--
2.7.4