[Mono-list] RE: Writing daemons in C#

Erik Bågfors erik@bagfors.nu
19 Nov 2002 12:35:25 +0100


For a unix-type daemon, the simplest thing to do for such a program is
to simply make a normal program and run it in the background (by
starting it with "mono program.exe &" or "nohup mono program.exe &"
depending on what you want.

There is nothing magical about a daemon except that it normally forks
and setsid's itself (which you don't really have to worry about if you
start it as written above).  If you want to make it into a "real"
unix-daemon then learn how to pinvoke fork and setsid or write a library
for it.

The really cool thing would be if you or someone else implemented the
service-stuff from windows for mono and then you could use that.

/Erik

On Thu, 2020-11-19 at 10:11, Aschwin Wesselius wrote:
> Thanks guys. I will define "daemons" a bit more.
>  
> What I want is a program listening on a port, just like FTP or maybe
> an instant messaging bot based on Alice (www.alicebot.org). Since I
> don't know any C or C++ I would want to do it in C#, or else I have to
> forget the whole idea.
> So to start off, I need to know if it is possible and next, I would go
> to figure out how to write daemons in general.
>  
> There is actually no documentation to find on the internet about
> writing daemons or how to set them up to run in the background. Maybe
> I just look for the wrong keywords, or google is playing games with me
> = )
>  
> And yes, writing a service/daemon once might become easier to have it
> both on windows and on unix/linux.
>  
> So there is no "need" for C# doing daemons, but in my case it might
> become helpfull. C and C++ will still be very good languages for that,
> I know. But in general I was just curious how to built them and set
> them up, and I would do it in C#.
>  
> I hope it is more clear now.....
>  


-- 
Erik Bågfors               | erik@bagfors.nu
Supporter of free software | GSM +46 733 279 273
fingerprint: 6666 A85B 95D3 D26B 296B 6C60 4F32 2C0B 693D 6E32