Does POSIX permit a NULL 'environ' variable? I'd say no given what
http://www.opengroup.org/onlinepubs/9699919799/functions/environ.html
has to say:
In addition, the following variable:
extern char **environ;
is initialized as a pointer to an array of character pointers to the
environment strings. The argv and environ arrays are each terminated
by a null pointer.
Strictly speaking, I don't think NULL is a valid array of character
pointers terminated with a null pointer.
I've noticed that Wine uses one:
j...@mocca:~$ cat environ-wine.c
#include <stdio.h>
#include <stddef.h>
#include <stdlib.h>
int main (void)
{
if (environ == NULL)
puts("NULL");
else
puts("non-NULL");
return 0;
}
j...@mocca:~$ i686-w64-mingw32-gcc -o environ-wine.exe environ-wine.c
j...@mocca:~$ ./environ-wine.exe
NULL
j...@mocca:~$
The same EXE file prints non-NULL on real Windows.
This crashes the test-environ.c and test-unsetenv.c self tests.
/Simon