> > thanks for the analysis > > so it would be bad behavior to block all threads in > the parent > until the vfork() returns? > > doesn't a single threaded parent process block until > vfork() > returns anyway?
Actually, all threads in the parent are blocked until the vforkd child calls exec() or exit(). The wait() race I referred to before occurs when the child calls exit(). At that moment, all of the parent's threads are made runnable and the other thread in wait() may see the process before the posix_spawn() thread gets to dispose of it. Of course, this is what obtains when the posix_spawn() call succeeds, but when posix_spawn() fails (returns non-zero), the Posix spec says that no child process shall be created. The implementation actually creates a child process when posix_spawn() fails with an error from the child, but if the failing child can be made to disappear completely then it is "as if" the child had never been created. Roger Faulkner Sun Microsystems This message posted from opensolaris.org