How to install daemons? |
Gentoo Mono Handbook
services |
UnixSignal intr = new UnixSignal (Signum.SIGINT);
UnixSignal term = new UnixSignal (Signum.SIGTERM);
UnixSignal hup = new UnixSignal (Signum.SIGHUP);
UnixSignal usr2 = new UnixSignal (Signum.SIGUSR2);
UnixSignal[] signals = new UnixSignal[] { intr, term, hup, usr2 };
for (bool running = true; running; )
{
int idx = UnixSignal.WaitAny(signals);
if (idx < 0 || idx >= signals.Length) continue;
log.Debug("daemon: received signal " + signals[idx].Signum.ToString());
if ((intr.IsSet || term.IsSet))
{
intr.Reset ();
term.Reset ();
log.Debug("daemon: stopping...");
running = false;
}
else if (hup.IsSet)
{
// Ignore. Could be used to reload configuration.
hup.Reset();
}
else if (usr2.IsSet)
{
usr2.Reset();
// do something
}
}