Skip to content

Instantly share code, notes, and snippets.

@jonpryor
Created January 3, 2012 15:05
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jonpryor/1555261 to your computer and use it in GitHub Desktop.
Save jonpryor/1555261 to your computer and use it in GitHub Desktop.
using System;
using System.Threading;
using Mono.Unix;
using Mono.Unix.Native;
class Test {
static void Main ()
{
StartHandler();
Console.WriteLine("Press any key to exit...");
Console.ReadLine();
}
static void StartHandler()
{
new Thread(TerminateHandler).Start();
}
static void TerminateHandler()
{
Console.WriteLine("Initializing Handler for SIGINT");
UnixSignal signal = new UnixSignal(Signum.SIGINT);
while(signal.WaitOne())
{
Console.WriteLine("Control-C Pressed!");
break;
}
Console.WriteLine("handler Terminated");
}
}
@Delfic
Copy link

Delfic commented Jun 12, 2019

What about if I want to handle multiple instances of the same signal?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment