LCOV - code coverage report
Current view: top level - synthesis/Utilities - SigHandler.cc (source / functions) Hit Total Coverage
Test: casacpp_coverage.info Lines: 20 26 76.9 %
Date: 2024-12-11 20:54:31 Functions: 6 7 85.7 %

          Line data    Source code
       1             : // -*- C++ -*-
       2             : //# SigHandler.cc: Implementation of the signal handling  class
       3             : //# Copyright (C) 2012
       4             : //# Associated Universities, Inc. Washington DC, USA.
       5             : //#
       6             : //# This library is free software; you can redistribute it and/or modify it
       7             : //# under the terms of the GNU Library General Public License as published by
       8             : //# the Free Software Foundation; either version 2 of the License, or (at your
       9             : //# option) any later version.
      10             : //#
      11             : //# This library is distributed in the hope that it will be useful, but WITHOUT
      12             : //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
      13             : //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
      14             : //# License for more details.
      15             : //#
      16             : //# You should have received a copy of the GNU Library General Public License
      17             : //# along with this library; if not, write to the Free Software Foundation,
      18             : //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
      19             : //#
      20             : //# Correspondence concerning AIPS++ should be addressed as follows:
      21             : //#        Internet email: casa-feedback@nrao.edu.
      22             : //#        Postal address: AIPS++ Project Office
      23             : //#                        National Radio Astronomy Observatory
      24             : //#                        520 Edgemont Road
      25             : //#                        Charlottesville, VA 22903-2475 USA
      26             : //#
      27             : //# $Id$
      28             : 
      29             : #include <synthesis/Utilities/SigHandler.h>
      30             : #include <casacore/casa/BasicSL/String.h>
      31             : 
      32             : //DEDICATED TO HONGLIN YE 
      33             : 
      34             : 
      35             : 
      36             : using namespace casacore;
      37             : namespace casa { 
      38             :   bool SigHandler::killOn_p = false;
      39          14 :   SigHandler::SigHandler()
      40             :   {
      41          14 :     setupSignalHandlers();
      42          14 :     setStopSignal(false);
      43          14 :   }
      44             : 
      45          14 :   SigHandler::~SigHandler()
      46             :   {
      47          14 :   }
      48             : 
      49          14 :   void SigHandler::setupSignalHandlers(){
      50             :     
      51          14 :     signal(SIGABRT, &(SigHandler::theHandler));
      52          14 :     signal(SIGINT, &(SigHandler::theHandler));
      53             :            
      54             :            
      55          14 :   }
      56         130 :   void SigHandler::resetSignalHandlers(){
      57         130 :     signal(SIGABRT, SIG_DFL);
      58         130 :     signal(SIGINT, SIG_DFL);
      59         130 :     killOn_p=false;
      60         130 :   }
      61             : 
      62         263 :   Bool SigHandler::gotStopSignal(){
      63         263 :     return killOn_p;    
      64             :   }
      65             : 
      66           0 :   void SigHandler::theHandler(int sig){
      67           0 :     String smoke="n ABORT ";
      68           0 :     if(sig==SIGINT) smoke="n INTERRUPT ";
      69           0 :     cerr << ("Caught a"+smoke+ " signal. Please wait ...");
      70           0 :     killOn_p=true;
      71           0 :   }
      72             : 
      73          14 :   void SigHandler::setStopSignal(Bool lala){
      74          14 :     killOn_p=lala;
      75          14 :   }
      76             :   
      77             : 
      78             : 
      79             : };//end namespace

Generated by: LCOV version 1.16