I am working on some posix_spawn tests for the new stc repository [1], and
making sure they behave the same between Cygwin and Linux.  I found one
case (so far) which does not: passing NULL for argument "envp" to
posix_spawn.

In Cygwin, this results in the child inheriting the environment from the
caller (same as passing "environ"), but on Linux this results in the child
getting an empty environment (same as passing a char *envp[] = {NULL}).

The Open Group doc on posix_spawn doesn't seem to say anything about the
potential for envp being NULL, but does mention

> For the Ada language binding for Start_Process to be implemented with
> posix_spawn(), that binding would need to explicitly pass an empty
> signal mask and the parent's environment to posix_spawn() whenever the
> caller of Start_Process allowed these arguments to default, since
> posix_spawn() does not provide such defaults.

That at least implies that passing NULL does not default to using the
parent's environment.

Thoughts?  Is this a bug in Cygwin, or "undefined behavior" that it's
perfectly within its rights to do whatever it feels like in response
(empty environment or inherited environment, or crash every second
Tuesday)?

-- 
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple

Reply via email to