[clamav-users] Windows service

Micah Snyder (micasnyd) micasnyd at cisco.com
Fri Jul 5 20:58:54 UTC 2019


Regarding the foreground option on Windows, clamd.exe remains in the foreground regardless of the setting.  This is intentional, because programs in Windows aren't expected to background themselves. It's not normal behavior.  

A daemon on Posix systems is just an ordinary program that creates a backgrounded copy of itself.  A service on Windows is not an ordinary program.  A service implements functions to handle starting, stopping, and restarting of the service.  A service written in C or C++ implements ServiceMain instead of main or WinMain.  MSDN reference for details: https://docs.microsoft.com/en-us/windows/win32/services/writing-a-servicemain-function   Clamd.exe does not implement ServiceMain, and thus can't be run as a service. 

You may have some success wrapping clamd.exe in a service.  One way to do this would be to implement a service in Powershell that runs clamd.exe.  It's been some time since I tried anything like this though, so the specifics are really hazy to me.  I tried searching online for instructions on how to do this and came up with this: https://msdn.microsoft.com/en-us/magazine/mt703436.aspx.  I'm not sure if that helps any. 

Micah


On 7/5/19, 12:39 PM, "clamav-users on behalf of lists--- via clamav-users" <clamav-users-bounces at lists.clamav.net on behalf of clamav-users at lists.clamav.net> wrote:

    I am trying to set up a Windows service running clamd.exe. At first I was 
    running into a timeout 
    issue whereby it would take too long to start, so the service manager would 
    kill it. So I increased
    the value of ServicesPipeTimeout to 60 seconds. That took care of that 
    problem.
    
    Now I can see in the clamd.log that the process finishes starting up, but 
    Windows doesn't
    recognize it. So once the 60 seconds comes around, it kills the clamd.exe 
    process. I have tried
    both foreground and daemonizing the clamd.exe process, both with the same 
    result.
    
    Am I missing something?
    
    _______________________________________________
    
    clamav-users mailing list
    clamav-users at lists.clamav.net
    https://lists.clamav.net/mailman/listinfo/clamav-users
    
    
    Help us build a comprehensive ClamAV guide:
    https://github.com/vrtadmin/clamav-faq
    
    http://www.clamav.net/contact.html#ml
    



More information about the clamav-users mailing list