Back to index

courier  0.68.2
exittrap.h
Go to the documentation of this file.
00001 #ifndef       exittrap_h
00002 #define       exittrap_h
00003 
00004 
00005 #include      "config.h"
00006 
00008 //
00009 // ExitTrap implements exit traps - cleanup functions that must be called
00010 // in case of an abnormal program termination.
00011 //
00012 // This class does NOT do anything like trap signals, etcetera.  The main
00013 // program should do that, and call onexit() in order to call the cleanup()
00014 // virtual function.
00015 //
00017 
00018 class ExitTrap {
00019 
00020        ExitTrap      *next, *prev;
00021        virtual void  cleanup()=0;
00022        virtual void  forked()=0;
00023        int    callcleanup;
00024 protected:
00025        void   destroying() { callcleanup=0; }
00026        void   constructed() { callcleanup=1; }
00027 public:
00028        ExitTrap();
00029        virtual ~ExitTrap();
00030 
00031 static void   onexit();
00032 static void   onfork();
00033 } ;
00034 #endif