usr_signals.H

Go to the documentation of this file.
00001 #ifndef USR_SIGNALS_HEADER
00002 #define USR_SIGNALS_HEADER
00003 
00009 #include <csignal>
00010 
00011 // this is tiny and somewhat "dirty"
00012 // the stuff presented here is not interrupt-safe!
00013 // so it could be that a signal just gets lost!
00014 // (but in the moment we just don't care about...)
00015 
00016 class Cusr_signal_proxy
00017 {
00018 private:
00019  static bool SIGUSR1_received;
00020  static bool SIGUSR2_received;
00021  static void signalhandler(int signal);
00022  sighandler_t dflusr1, dflusr2;
00023  bool previous1,previous2;
00024 public:
00025  Cusr_signal_proxy()
00026   {
00027     previous1=SIGUSR1_received; SIGUSR1_received=false;
00028     dflusr1=signal(SIGUSR1,signalhandler);
00029     previous2=SIGUSR2_received; SIGUSR2_received=false;
00030     dflusr2=signal(SIGUSR2,signalhandler);
00031   }
00032  ~Cusr_signal_proxy()
00033   {
00034     SIGUSR1_received=previous1;
00035     dflusr1=signal(SIGUSR1,dflusr1);
00036     SIGUSR2_received=previous2;
00037     dflusr1=signal(SIGUSR2,dflusr2);
00038   }
00039  const bool got_SIGUSR1()
00040   {
00041     if (SIGUSR1_received) { SIGUSR1_received=false; return true; }
00042     return false;
00043   }
00044  const bool got_SIGUSR2()
00045   {
00046     if (SIGUSR2_received) { SIGUSR2_received=false; return true; }
00047     return false;
00048   }
00049 };
00050 
00051 #endif /* USR_SIGNALS_HEADER */

Generated on Wed Nov 7 23:29:26 2007 for Qsieve by  doxygen 1.5.4