[PATCH] crond: add LOG_NDELAY to openlog

David Laight David.Laight at ACULAB.COM
Tue Dec 12 09:08:43 UTC 2023


From: Jones Syue
> Sent: 12 December 2023 01:49
> 
> > You aren't allowed to do very much between vfork() and exec().
> > Basically just sort out the child's fd table.
> > And I suspect that needs to only look at on-stack data.
> >
> > Having the child execute first is only an optimisation.
> > The child can fault on paged-out memory (even its stack) which
> > would allow the parent to run.
> 
> Yes. Definitely!  :)
> And per man page 'On some implementations, vfork() is equivalent to fork().'
> race conditions between parent and children is possible too,
> depends on implementation.
> https://linux.die.net/man/3/vfork
> https://man7.org/linux/man-pages/man2/vfork.2.html
> 
> A possible approach is: let crond parent prepare the DGRAM socket fd
> connecting to /dev/log, avoid been delayed connecting until the first
> message is logged by vfork() children.

I'd actually suggest using fork() - much safer.
While slightly slower no one is going to notice the difference
when cron is running programs.

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)



More information about the busybox mailing list