Laurent Wacrenier wrote:

> What's the trouble with system() ?

It waits for the called script to complete.  I had a situation earlier this 
morning
where freshclam got hung up for 9 hours due some or other fault.  Whatever you 
choose to put 
in OnXXXXExecute, it should not stop/affect the freshclam process.

> - The system shell may not be /bin/sh everywhere.

system() uses /bin/sh -c on Linux - I wanted to keep the existing behaviour of 
system().

> - You should check if fork() returns -1

Agree.

> - You should wait for the child pid instead of any child
>   and loop on waitpid().
> - As waitpid() is called once with the WNOHANG flags,
>   you may have some zombie process, or if a bogus child never exits,
>   you will have tons of childs and your process table will be full.

waitpid() was actually called on every iteration - i.e. for every check.  But, 
I've changed 
it to use SIGCHLD now - much easier.

http://jessen.ch/files/patch-clamav-0.83-freshclam-with-fork2


Many thanks for the feedback, Laurent.


/Per Jessen, Zürich

_______________________________________________
http://lurker.clamav.net/list/clamav-devel.html

Reply via email to