[Mono-list] c# written daemon, System.ServiceProcess, posix signals handling...

Fawad Halim fawad@fawad.net
Fri, 16 Apr 2004 09:26:20 -0500


Hi Robert,
    I'd suggest running your app under runit 
(http://smarden.org/runit/). That'll take care of making sure the app is 
always running even when killed abnormally. When you 'down' the service 
in runit, it sends it a SIGTERM and maintains an internal flag that the 
service is supposed to be down intentionally. There is a thread on 
signal handlers in the March '03 archive of mono-list, including an 
example of a sigterm handler using unmanaged calls.

-fawad

RoBiK wrote:

>Hi!
>
>I need to write an application in c#, wich should run in background and be
>able to shut down gracefully when required.
>The best solution would be to use the System.ServiceProcess namespace, but
>this namespace is not implemented in mono. I know that there were some
>discussion about this topic in summer 2003, but since i found nothing. Is
>there something new in this direction?
>The other way (not so nice, but would also do the job) would be the catching
>of posix signals (SIGINT, SIGTERM...) but i have no idea how to do thin in
>an mono application.
>The last solution is to use some selfmade communication mechnism, to
>comunicate with the process and initiate the shutdow - maybe using remoting
>or some simpler mechanism.
>Can someone give me some infos or ideas for the solution?
>
>Thanx
>
>Robert
>