Joerg Schilling writes: > Roland Mainz <roland.mainz at nrubsig.org> wrote: > > > Erm... why does |posix_spawn()| call |vfork()| in this case ? The > > vfork(2) manual page says this function call is depreciated... > > This is in the manual page since vfork() exists.... > > Vfork() is the only way to implement posix_spawn() the way you like > (efficient).
If you look at the internal implementation of posix_spawn(), you'll see that it does things to avoid the pitfalls of vfork and the dynamic linker. Additionally, if something in the system were to change in the future such that vfork() became more of a problem, posix_spawn() (as a safe alternative) would get those fixes. Programs calling vfork() might not. The man page doesn't just say that it's deprecated. It says: The vfork() function is deprecated. Its sole legitimate use as a prelude to an immediate call to a function from the exec family can be achieved safely by posix_spawn(3C) or posix_spawnp(3C). The only legitimate thing you can do with it is to call exec right away, and if you're going to do that, then the spawn function is simpler and better. -- James Carlson, KISS Network <james.d.carlson at sun.com> Sun Microsystems / 1 Network Drive 71.232W Vox +1 781 442 2084 MS UBUR02-212 / Burlington MA 01803-2757 42.496N Fax +1 781 442 1677