]> git.ipfire.org Git - thirdparty/libbsd.git/commitdiff
Declare environ if the system does not do so
authorGuillem Jover <guillem@hadrons.org>
Sat, 1 Apr 2023 10:41:42 +0000 (12:41 +0200)
committerGuillem Jover <guillem@hadrons.org>
Mon, 17 Apr 2023 02:12:42 +0000 (04:12 +0200)
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
<unistd.h> and defining _GNU_SOURCE.

configure.ac
src/setproctitle.c

index 17978b18c07078587346894963f361514b43575e..4a3c8b00cc3e351c847bc4687cdfcc5d97448d02 100644 (file)
@@ -194,6 +194,10 @@ AC_CHECK_DECL([F_CLOSEM], [
 #include <fcntl.h>
 ]])
 
+AC_CHECK_DECLS([environ], [], [], [[
+#include <unistd.h>
+]])
+
 AC_CACHE_CHECK([for GNU .init_array section support],
   [libbsd_cv_gnu_init_array_support], [
   AC_RUN_IFELSE([
index d3e10876d42e588d9f99f96421dbf05e27185ce9..64ff92a96c0e89edb0dc4a5d19e060ef13420bfd 100644 (file)
 #include <string.h>
 #include "local-link.h"
 
+#if !HAVE_DECL_ENVIRON
+extern char **environ;
+#endif
+
 static struct {
        /* Original value. */
        const char *arg0;