From 6afeb7badcb76a509916ff4f0a3ae36599cae474 Mon Sep 17 00:00:00 2001 From: Eric Blake Date: Thu, 31 May 2018 08:52:40 -0500 Subject: [PATCH] doc: mention environ pitfall Based on a bug report to the Cygwin list: https://cygwin.com/ml/cygwin/2018-05/msg00321.html * doc/posix-functions/environ.texi (environ): Assigning NULL to environ is a glibc extension. Signed-off-by: Eric Blake --- ChangeLog | 6 ++++++ doc/posix-functions/environ.texi | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/ChangeLog b/ChangeLog index 013d21a6e8..23689545af 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2018-09-05 Eric Blake + + doc: mention environ pitfall + * doc/posix-functions/environ.texi (environ): Assigning NULL to + environ is a glibc extension. + 2018-09-03 Bruno Haible gnulib-tool: Fix build order when $testsbase is a subdir of $sourcebase. diff --git a/doc/posix-functions/environ.texi b/doc/posix-functions/environ.texi index a6c00958da..8f8370aa9f 100644 --- a/doc/posix-functions/environ.texi +++ b/doc/posix-functions/environ.texi @@ -34,4 +34,11 @@ Portability problems not fixed by Gnulib: @item The address of this variable is not a compile-time constant on some platforms: mingw. +@item +Assigning NULL to @code{environ} to clear all variables is not +portable; better is to assign @code{environ} to one-element array +containing a NULL pointer. That said, an empty environment is not +portable either, as some systems may require particular environment +variables (such as @code{PATH}) to be present in order to operate +consistently. @end itemize -- 2.39.5