From 44824aca3cae1a3908f80216ff8e53f859d16dc4 Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Sat, 1 Apr 2023 12:41:42 +0200 Subject: [PATCH] Declare environ if the system does not do so The environ variable is supposed to be defined by the code using it, but on glibc-based systems it will get defined if we request it, by including and defining _GNU_SOURCE. --- configure.ac | 4 ++++ src/setproctitle.c | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/configure.ac b/configure.ac index 17978b1..4a3c8b0 100644 --- a/configure.ac +++ b/configure.ac @@ -194,6 +194,10 @@ AC_CHECK_DECL([F_CLOSEM], [ #include ]]) +AC_CHECK_DECLS([environ], [], [], [[ +#include +]]) + AC_CACHE_CHECK([for GNU .init_array section support], [libbsd_cv_gnu_init_array_support], [ AC_RUN_IFELSE([ diff --git a/src/setproctitle.c b/src/setproctitle.c index d3e1087..64ff92a 100644 --- a/src/setproctitle.c +++ b/src/setproctitle.c @@ -33,6 +33,10 @@ #include #include "local-link.h" +#if !HAVE_DECL_ENVIRON +extern char **environ; +#endif + static struct { /* Original value. */ const char *arg0;