2

I created a Server that listens for HTTP connections all the time. It's a default Console Application and runs on a Linux Machine using Mono (2.4).

The Problem is that i want this Server to move itself to the background (deamonize itself). I couldn't find a Solution on Google and mono Server.exe & is not really what i'm looking for (the effect is the correct, i just want the program to do it itself), eventhough it works for the moment.

Any hints/ideas?

  • 2
    This question is a duplicate. It's been asked here: http://stackoverflow.com/questions/186493/how-do-i-code-a-mono-daemon The answer is to use mono-service. – supercheetah Apr 23 '10 at 19:15

2 Answers2

2

Well about the best it can do is span another copy of itself with system.diagnositics.process.

If you're willing to be *nix specific you can P/Invoke daemonize(), which is: fork(), and parent calls _exit while child calls setpgrp(0).

Joshua
  • 40,822
  • 8
  • 72
  • 132
  • Thanks, this should work, eventhough it feels a little clumsy. I'll try it but i hope someone else knows something simpler and more straight forward. –  Apr 23 '10 at 18:50
0

I'm using mono-service now.