[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:

                addconn_child_pid = vfork(); /* for better, for worse,
in sickness and health..... */
                addconn_child_pid = fork();
                if (addconn_child_pid == 0) {
                        /* child */
                            DBG_log("calling addconn helper using execve"));
                        execve(addconn_path, newargv, newenv);

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.


More information about the Swan-dev mailing list