[Swan-dev] use vfork/exec

David McCullough ucdevel at gmail.com
Fri Oct 16 23:10:24 UTC 2015


Andrew Cagney wrote the following:
> On 16 October 2015 at 16:56, Paul Wouters <paul at nohats.ca> wrote:
> >
> > The debug printing can easilly be moved.
> >
> > The sleep was there to ensure the parent had continued, and when the
> > addconn fork is calling the parent on the socket in /var/run, there
> > is something listening. If that is actually needed, we could add it
> > as an option to addconn to pause for one second there.
> 
> My guess (incorrect) was that it was trying to keep log messages
> somewhat in sync.   Ewww.
> 
> Thanks for the background.  Yea, technically, it should either use
> synchronization (pipes for instance); but, sigh, I guess a while loop
> with a sleep to make it really clear what it is waiting for would also
> work.


Just remember that with vfork and the code in question,  the parent is
blocked until after the exec, so the sleep does nothing but slow the whole
process down by 1 second :-)

Also,  IIRC "exit" is not vfork safe,  _exit() should be used instead.

Cheers,
Davidm

> BTW, if there's code lurking that is turning a process into a daemon
> (fork/fork/exec) is one technique; then that should be changed to just
> call daemon().
> 
> Andrew
> _______________________________________________
> Swan-dev mailing list
> Swan-dev at lists.libreswan.org
> https://lists.libreswan.org/mailman/listinfo/swan-dev

-- 
David McCullough,  ucdevel at gmail.com,   Ph: 0410 560 763


More information about the Swan-dev mailing list