bug-cfengine
[Top][All Lists]
Advanced

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

RE: Getting cfservd.exe to become a windows service using cygruns rv


From: Andrews, Martin
Subject: RE: Getting cfservd.exe to become a windows service using cygruns rv
Date: Wed, 24 Apr 2002 14:45:09 -0400

David,

Sounds good to me - in fact I applied a similar patch to use select() for
cfengine 1.6 because 1.6 depended on receiving a timer signal while waiting
on an accept(). It worked on all platforms.

Martin

-----Original Message-----
From: David Reiter [mailto:address@hidden
Sent: Wednesday, April 24, 2002 11:57 AM
To: address@hidden
Subject: Getting cfservd.exe to become a windows service using cygrunsrv


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.



_______________________________________________
Bug-cfengine mailing list
address@hidden
http://mail.gnu.org/mailman/listinfo/bug-cfengine



reply via email to

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