Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

/Go4Socket/TGo4SocketSignalHandler.cxx

Go to the documentation of this file.
00001 //---------------------------------------------------------------
00002 //        Go4 Release Package v2.10-5 (build 21005) 
00003 //                      03-Nov-2005
00004 //---------------------------------------------------------------
00005 //       The GSI Online Offline Object Oriented (Go4) Project
00006 //       Experiment Data Processing at DVEE department, GSI
00007 //---------------------------------------------------------------
00008 //
00009 //Copyright (C) 2000- Gesellschaft f. Schwerionenforschung, GSI
00010 //                    Planckstr. 1, 64291 Darmstadt, Germany
00011 //Contact:            http://go4.gsi.de
00012 //----------------------------------------------------------------
00013 //This software can be used under the license agreements as stated
00014 //in Go4License.txt file which is part of the distribution.
00015 //----------------------------------------------------------------
00016 #include "TGo4SocketSignalHandler.h"
00017 
00018 #include <signal.h>
00019 #include <iostream.h>
00020 
00021 
00022 Int_t TGo4SocketSignalHandler::fgiLastSignal = 0; // unix signal id
00023 
00024 TGo4SocketSignalHandler::TGo4SocketSignalHandler(Int_t signum, Bool_t enabled)
00025 {
00026    SetSignalAction(signum,enabled);
00027    //cout << "set member function as signal handler"<< endl;
00028 }
00029 
00030 TGo4SocketSignalHandler::~TGo4SocketSignalHandler()
00031 {
00032 }
00033 
00034 void TGo4SocketSignalHandler::Handle(Int_t signum)
00035 {
00036    SetSignalAction(signum,0);
00037    //cout << "got a signal " << signum << " ("<< getpid() << ") Id: ";
00038 // optional part:
00039 //   if(signum == SIGWINCH)
00040 //      {
00041 //         //cout << "got a SIGWINCH\n";
00042 //         //TGo4SocketSignalHandler::fgiLastSignal = SIGWINCH;
00043 //
00044 //       }
00045 // end optional part
00046    TGo4SocketSignalHandler::fgiLastSignal = signum;
00047    SetSignalAction(signum,1);
00048 }
00049 
00050 void TGo4SocketSignalHandler::SetSignalAction(Int_t signum, Bool_t enabled)
00051 {
00052   struct sigaction new_action, old_action;
00053 
00054   /* Set up the structure to specify the new action. */
00055   if(enabled)
00056     new_action.sa_handler = (void(*) (int)) TGo4SocketSignalHandler::Handle ;
00057   else
00058     new_action.sa_handler = SIG_IGN;
00059 
00060   sigemptyset (&new_action.sa_mask);
00061   new_action.sa_flags = 0;
00062   sigaction (signum, NULL, &old_action);
00063   if(enabled)
00064     sigaction (signum, &new_action, NULL);
00065 }
00066 
00067 //----------------------------END OF GO4 SOURCE FILE ---------------------

Generated on Tue Nov 8 10:56:05 2005 for Go4-v2.10-5 by doxygen1.2.15