diff --git a/configure.ac b/configure.ac index f644dd2c5..d0a2dc79b 100644 --- a/configure.ac +++ b/configure.ac @@ -516,6 +516,7 @@ AC_CHECK_HEADERS([crt_externs.h]) # sendfile - non-POSIX, found in glibc # pipe2 - non-POSIX, found in glibc (GNU/Linux and GNU/Hurd) # posix_spawn_file_actions_addclosefrom_np - glibc >= 2.34 +#...clearenv - non-POSIX, found in glibc # AC_CHECK_FUNCS([DINFINITY DQNAN cexp chsize clog clog10 ctermid \ fesetround ftime ftruncate fchown fchownat fchmod fchdir readlinkat \ @@ -530,7 +531,8 @@ AC_CHECK_FUNCS([DINFINITY DQNAN cexp chsize clog clog10 ctermid \ strcoll_l strtod_l strtol_l newlocale uselocale utimensat \ fstatat futimens openat \ sched_getaffinity sched_setaffinity sendfile pipe2 \ - posix_spawn_file_actions_addclosefrom_np]) + posix_spawn_file_actions_addclosefrom_np \ + clearenv]) # The newlib C library uses _NL_ prefixed locale langinfo constants. AC_CHECK_DECLS([_NL_NUMERIC_GROUPING], [], [], [[#include ]]) diff --git a/libguile/posix.c b/libguile/posix.c index 4ca8d5ff7..6ce78ee18 100644 --- a/libguile/posix.c +++ b/libguile/posix.c @@ -1773,7 +1773,11 @@ SCM_DEFINE (scm_environ, "environ", 0, 1, 0, { /* Arrange to not use GC-allocated storage for what goes into 'environ' as libc might reallocate it behind our back. */ +#if HAVE_CLEARENV clearenv (); +#else + environ = NULL; +#endif while (!scm_is_null (env)) { scm_putenv (scm_car (env));