> Should ksh93/libshell use |posix_spawn()| instead of |vfork()| ? it should and it does
all ast and ksh fork()/exec() is done by the ast spawnveg() which configures to the local system at compile time if posix_spawn is available then it is used a few other non-standard fork+exec combinations are also checked before vfork+exec, finally defaulting to fork+exec note that there are instances where ksh prefers pure fork() although it can work around that too On Tue, 24 Oct 2006 08:33:33 -0400 Greg Nakhimovsky wrote: > > While working on another bug I read > > http://blogs.sun.com/quenelle/entry/vfork_and_posix_spawn , > > http://developers.sun.com/solaris/articles/subprocess/subprocess.html > > and the Solaris 11/B48 |vfork()| manual page (which says: > > -- snip -- > > 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). > > -- snip -- > > ) ... > > ... which raises the question whether ksh93 should (or could) use > > |posix_spawn()| instead of |vfork()| > Yes. Whenever posix_spawn() is available, its use is preferable > to fork() or vfork() followed by exec(). > Note that you can dynamically determine if it's available and use > it only when it is, see > http://developers.sun.com/solaris/articles/subprocess/subprocess.html#avail posix_spawn needs <spawn.h> you use dlsym() to determine if the "posix_spawn" function exists -- ok but then there's instructions on copying a <spawn.h> from a newer system to an older if the local system doesn't have it I guess if you #ifdef solaris all of that its ok no way that is guaranteed to work in the wild -- Glenn Fowler -- AT&T Research, Florham Park NJ --