Glenn Fowler wrote: ... > I fixed those, but posix_spawn() was still found unworthy > the reason is that at least on solaris 10, posix_spawn() returns 0 (success) > when the executable file is empty > truss shows the underlying execve() getting ENOEXEC (which it should), > but that errno fails to make its way back as the posix_spawn() return value > > note that linux posix_spawn() is not worthy for the same reason
Most likely, posix_spawn() is supposed to return 0 (success) when the executable file is empty. It IS a little weird and confusing indeed, but that's how POSIX defined this interface. See the following explanation in my paper: http://developers.sun.com/solaris/articles/subprocess/subprocess.html#interf "Note how posix_spawn_example2.c performs error detection. It checks for an error code returned from each function related to posix_spawn(). In addition, it checks for error code 127 that may be returned from the child process to indicate a problem there. See the ERRORS section of the posix_spawn(3C) man page (reference [1]) for details of when the child process may exit with status 127." -Greg