[Mono-dev] [PATCH] System.ServiceProcess API compatibilityfixes - try #2
joerg.rosenkranz at gmail.com
Tue Sep 5 07:54:32 EDT 2006
2006/9/5, Gert Driesen <gert.driesen at telenet.be>:
> Now that you bring it up, could you explain how the mono-service
> implementation works. I've never looked into it.
> Is it a daemon ?
First it was a C daemon embedding Mono. For easier implementation it
was converted to a C# EXE which is run in the background by the
mono-service starter script.
A service on Windows has a somewhat strange behaviour which I had to
mimic on Linux. The service's Main entry point has to run the static
ServiceBase.Run method which does all the service handling. This
method returns after the last service of this EXE is stopped in the
Service Control Manager. To get control from ServiceBase back to
mono-service there is an internal callback function named RunService
inside of ServiceBase. Mono-service loads the service assembly,
registers the callback using Reflection and runs the assembly's entry
point. Inside the callback function it does all the Start, Stop, etc.
Mono-service is controlled by signals (SIGUSR1, SIGUSR2 and SIGTERM)
from the outside.
I don't know how to implement this handling on Windows because I
haven't done much low level service programming yet. Maybe it's easier
to fork the execution in ServiceBase.Run based on the operating system
than to implement an equivalent infrastructure on both sides?
More information about the Mono-devel-list