bug-cfengine
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Getting cfservd.exe to become a windows service using cygrunsrv


From: David Reiter
Subject: Getting cfservd.exe to become a windows service using cygrunsrv
Date: Wed, 24 Apr 2002 08:57:21 -0700 (PDT)

Hi,

 After getting cfagent working correctly I decided to make cfservd.exe
a service so I could use cfrun to update my windows box. But using
cygrunsrv I would get errors from windows when trying to stop
the service. The problem was basically cfservd was ignoring the
INT signal that cygrunsrv sends when stopping the service.
You could also try this not even using services. If you start
up cfservd the only signal you can use to stop it is -9. 

 Now there is signal handling code in cfservd so I started to
wonder what was going on. It turns out that when the server is
sitting there waiting for connections (the accept call on line 
538 of cfservd.c) it ignores signals. I don't know why something
to do with windows/cygwin. But if you add a select call to wait
for the connection signals do seem to work when the server is
blocked on the select. So here are my modifications:

 add this variable at the start of StartServer
 fd_set rset;

 above the while loop at line 534 add these lines:
 FD_ZERO(&rset);
 FD_ET(sd,&rset);

 above the sd_reply = accept line at line 538 add this line:
 select((sd+1),&rset,NULL,NULL,NULL);

This seems to allow signals to get to the process which then
allows it to run as a service.

Here is my cygrunsrv command to install it:
cygrunsrv -I "Cfengine Service" -f "Cfengine daemon" --path 
/var/cfengine/bin/cfservd.exe -a "-v"

Any comments on the select addition? Any reason not to put it 
in for linux as well?

David.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]