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 0 : SigHandler::SigHandler() 40 : { 41 0 : setupSignalHandlers(); 42 0 : setStopSignal(false); 43 0 : } 44 : 45 0 : SigHandler::~SigHandler() 46 : { 47 0 : } 48 : 49 0 : void SigHandler::setupSignalHandlers(){ 50 : 51 0 : signal(SIGABRT, &(SigHandler::theHandler)); 52 0 : signal(SIGINT, &(SigHandler::theHandler)); 53 : 54 : 55 0 : } 56 0 : void SigHandler::resetSignalHandlers(){ 57 0 : signal(SIGABRT, SIG_DFL); 58 0 : signal(SIGINT, SIG_DFL); 59 0 : killOn_p=false; 60 0 : } 61 : 62 0 : Bool SigHandler::gotStopSignal(){ 63 0 : 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 0 : void SigHandler::setStopSignal(Bool lala){ 74 0 : killOn_p=lala; 75 0 : } 76 : 77 : 78 : 79 : };//end namespace