On Tue, 19 May 2015, Nach wrote:
> posix_spawn is supposed to return a value indicating an error when it fails.
> The specification for it is here:
> http://pubs.opengroup.org/onlinepubs/9699919799/functions/posix_spawn.html
...
> From the spec: Otherwise, no child process shall be created, the value
> stored into the variable pointed to by a non-NULL pid is unspecified,
> and *an error number shall be returned as the function return value*
> to indicate the error.

The standard also later says:

----
  These functions may fail if:

    [EINVAL]   The value specified by file_actions or attrp is invalid.

  If this error occurs after the calling process successfully returns from 
  the posix_spawn() or posix_spawnp() function, the child process may exit 
  with exit status 127.

  If posix_spawn() or posix_spawnp() fail for any of the reasons that 
  would cause fork() or one of the exec family of functions to fail, an 
  error value shall be returned as described by fork() and exec, 
  respectively (or, if the error occurs after the calling process 
  successfully returns, the child process shall exit with exit status 127).
----

The permission there to have the child process exit with exit status 127 
without successful execution of the target executable directly contradicts 
the apparent requirement of the RETURN VALUES section.

The rationale for the posix_spawn interface explicitly calls out that it 
was intended and desired for the interface to be implementable without 
kernel changes, so we believe this is an error in the RETURN VALUES 
section of the standard and do not feel this is a bug in our 
implementation.



Philip Guenther

Reply via email to