aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--compat/getprogname.c16
-rwxr-xr-xconfigure3
2 files changed, 19 insertions, 0 deletions
diff --git a/compat/getprogname.c b/compat/getprogname.c
index ee178b7..a243233 100644
--- a/compat/getprogname.c
+++ b/compat/getprogname.c
@@ -16,8 +16,24 @@
#include "../config.h"
+#ifdef HAVE_PROGRAM_INVOCATION_SHORT_NAME
+
+#include <errno.h>
+
+extern char *program_invocation_short_name;
+
+const char *
+getprogname(void)
+{
+ return program_invocation_short_name;
+}
+
+#else
+
const char *
getprogname(void)
{
return "gmid";
}
+
+#endif
diff --git a/configure b/configure
index 2943ac5..ff21509 100755
--- a/configure
+++ b/configure
@@ -49,6 +49,7 @@ HAVE_GETPROGNAME=
HAVE_LIBEVENT=
HAVE_LIBTLS=
HAVE_OPENSSL=
+HAVE_PROGRAM_INVOCATION_SHORT_NAME=
HAVE_PR_SET_NAME=
HAVE_RECALLOCARRAY=
HAVE_SETPROCTITLE=
@@ -233,6 +234,7 @@ runtest getprogname GETPROGNAME || true
runtest libevent LIBEVENT || true
runtest libtls LIBTLS || true
runtest openssl OPENSSL || true
+runtest program_invocation_short_name PROGRAM_INVOCATION_SHORT_NAME "" -D_GNU_SOURCE || true
runtest pr_set_name PR_SET_NAME || true
runtest recallocarray RECALLOCARRAY || true
runtest setproctitle SETPROCTITLE || true
@@ -283,6 +285,7 @@ cat <<__HEREDOC__
#define HAVE_EXPLICIT_BZERO ${HAVE_EXPLICIT_BZERO}
#define HAVE_GETPROGNAME ${HAVE_GETPROGNAME}
#define HAVE_LIBEVENT ${HAVE_LIBEVENT}
+#define HAVE_PROGRAM_INVOCATION_SHORT_NAME ${HAVE_PROGRAM_INVOCATION_SHORT_NAME}
#define HAVE_PR_SET_NAME ${HAVE_PR_SET_NAME}
#define HAVE_RECALLOCARRAY ${HAVE_RECALLOCARRAY}
#define HAVE_SETPROCTITLE ${SETPROCTITLE}