0

How can I make this program survive when receiving SIGUSR1 signal? I know in C, this can be done because SIGUSR is non-fatal signal. Right now, yes it can detect SIGINT as intended, but sending a SIGUSR1 kills it.

using System;
using Mono.Unix;
using Mono.Unix.Native;
using System.Threading;

namespace testapp {
class MainClass {
    public static void Main(string[] args) {
        while (true) {
            UnixSignal signal = new UnixSignal (Signum.SIGINT);
            if (signal.WaitOne (Timeout.Infinite, false)) {
                    // SIGINT generated
                    Console.WriteLine("got signal");
            }

            Console.WriteLine("here");
        }
    }
  }
}

The other posting does not really show it.. and i am not interested in delegates i want the above snippet to handle it and the above is the minimal.

In c, to deal this is to put signal handler or IGN

daparic
  • 3,794
  • 2
  • 36
  • 38
  • 2
    Possible duplicate of [Detect when console application is closing/killed?](https://stackoverflow.com/questions/6546509/detect-when-console-application-is-closing-killed) – flakes Jan 04 '18 at 04:45
  • THe crux of the problem is that the snippet code dies when it receives a signal not waited on... how do i fix that? – daparic Jan 04 '18 at 05:19

0 Answers0