On 2023-06-26, Marc Espie wrote: > Note that a NULL environment is undefined behavior according to POSIX. > If you read the OpenGroup description, it very clearly states that > envp is a pointer to a NULL terminated array. > > Does GNU/Linux at least document that passing a NULL pointer means no > environment for them ?
No, GNU/Linux does not document that. Neither NetBSD (which behaves like GNU/Linux on NULL envp) or FreeBSD (which behaves like OpenBSD) document that behavior. All three systems do check envp, handling it as a special case when NULL (either by passing the child an empty environment or a copy of the parent's environment), but none document such behavior. But, since OpenBSD does document such behavior, it is necessary to say that it is a special case not covered by the standard. Either do that or, like the others, do not document it at all.