This is an example of handling unix signals with SUE. What does this program do is intercepting SIGINT (Ctrl-C) and SIGQUIT (Ctrl-\); try pressing Ctrl-C to see it works, and press Ctrl-\ to cause the program to exit.
/* This demo program waits for a signal. Upon SIGINT (Ctrl-C) it prints a message telling you how much times you did this and advicing you to press Ctrl-\ instead (to generate SIGQUIT). Having SIGQUIT, it exits. */ #include <stdio.h> #include <signal.h> #include "sue_sel.hpp" class SigquitHandler : public SUESignalHandler { SUEEventSelector *selector; public: SigquitHandler(SUEEventSelector *a_sel) : SUESignalHandler(SIGQUIT) { selector = a_sel; } ~SigquitHandler() {} virtual void SignalHandle() { selector->Break(); } }; class SigintHandler : public SUESignalHandler { int count; public: SigintHandler() : SUESignalHandler(SIGINT) { count = 0; } ~SigintHandler() {} virtual void SignalHandle() { printf("You've pressed Ctrl-C %d time(s). Press Ctrl-\\ instead!\n", ++count); } }; int main() { SUEEventSelector selector; SigquitHandler quithandler(&selector); SigintHandler inthandler; selector.RegisterSignalHandler(&quithandler); selector.RegisterSignalHandler(&inthandler); printf("Entering the main loop... \n"); selector.Go(); printf("Main loop exited\n"); return 0; }