[Swan-dev] use vfork/exec
Andrew Cagney
andrew.cagney at gmail.com
Fri Oct 16 20:24:03 UTC 2015
I'd like to float the idea of simplifying pluto a little by
unconditionally using vfork/exec. For instance, in
programs/pluto/server.c, there is:
#ifdef HAVE_NO_FORK
addconn_child_pid = vfork(); /* for better, for worse,
in sickness and health..... */
#else
addconn_child_pid = fork();
#endif
if (addconn_child_pid == 0) {
/* child */
sleep(1);
DBG(DBG_CONTROLMORE,
DBG_log("calling addconn helper using execve"));
execve(addconn_path, newargv, newenv);
_exit(42);
}
I'd simplify it to just use vfork. That way, we're always testing a
single code path (and increasing the odds that on systems that don't
have fork, e.x., systems without an mmu) everything still works.
I should note that vfork() comes with caveats. Other than exec() and
exit() there's really not much else that is allowed between the
vfork() and exec() calls. The above, which calls sleep() and printf()
is likely wrong and I'd need to fix it.
Andrew
More information about the Swan-dev
mailing list