Detect when console application is closing/killed?
问题 I wanted to make a safe exit for my console application that will be running on linux using mono but I can't find a solution to detect wether a signal was sent to it or the user pressed ctrl+c. On windows there is the kernel function SetConsoleCtrlHandler which does the job but that doesnt work on mono. How do I get a closing event on my console application to safe exit it ? 回答1: You need to use Mono.UnixSignal , there's a good sample posted by Jonathan Pryor : http://www.jprl.com/Blog