On Fri, Feb 16, 2007 at 03:28:18PM +0000, Ian Abbott said: > On 16/02/2007 15:14, Stephen Gran wrote: > >What would be the point of having a socket ready before clamd is ready > >to do any work? Maybe I'm missing something. > > My proposal is to change the order from: > > * fork (daemonize) > * load database > * open sockets > > to: > > * load database > * open sockets > * fork (daemonize) > > So the socket still won't be ready until clamd is ready. The point is > to stop the initial process from exiting until everything is set up, so > that a script can run clamd (in daemonizing mode) and know that > everything is set up as soon as the command returns, rather than having > to sleep for some arbitrary and ill-defined amount of time afterwards.
Ah, that makes some sense. What I did in another application that needed this sort of thing was to have this sequence: parent: fork parent: sleep child: do setup (load databases here) child: open sockets child: signal parent that it was ready (sigusr1) parent: exit when signal received That way the parent sits foregrounded until the child is actually ready to do some work, and start up scripts take as long as that takes, so there's no race condition with sleeps. -- -------------------------------------------------------------------------- | Stephen Gran | Better late than never. -- Titus | | [EMAIL PROTECTED] | Livius (Livy) | | http://www.lobefin.net/~steve | | --------------------------------------------------------------------------
signature.asc
Description: Digital signature
_______________________________________________ Help us build a comprehensive ClamAV guide: visit http://wiki.clamav.net http://lurker.clamav.net/list/clamav-users.html