LCOV - code coverage report
Current view: top level - daemon - interrupt.cpp (source / functions) Hit Total Coverage
Test: coverage.info Lines: 10 10 100.0 %
Date: 2025-01-27 20:52:47 Functions: 3 4 75.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : // Copyright (c) 2016-2024  Made to Order Software Corp.  All Rights Reserved
       2             : //
       3             : // https://snapwebsites.org/project/cluck
       4             : // contact@m2osw.com
       5             : //
       6             : // This program is free software: you can redistribute it and/or modify
       7             : // it under the terms of the GNU General Public License as published by
       8             : // the Free Software Foundation, either version 3 of the License, or
       9             : // (at your option) any later version.
      10             : //
      11             : // This program is distributed in the hope that it will be useful,
      12             : // but WITHOUT ANY WARRANTY; without even the implied warranty of
      13             : // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      14             : // GNU General Public License for more details.
      15             : //
      16             : // You should have received a copy of the GNU General Public License
      17             : // along with this program.  If not, see <https://www.gnu.org/licenses/>.
      18             : 
      19             : 
      20             : // self
      21             : //
      22             : #include    "interrupt.h"
      23             : 
      24             : #include    "cluckd.h"
      25             : 
      26             : 
      27             : // last include
      28             : //
      29             : #include    <snapdev/poison.h>
      30             : 
      31             : 
      32             : 
      33             : namespace cluck_daemon
      34             : {
      35             : 
      36             : /** \class interrupt
      37             :  * \brief Handle the SIGINT Unix signal.
      38             :  *
      39             :  * This class is an implementation of the signalfd() specifically
      40             :  * listening for the SIGINT signal.
      41             :  */
      42             : 
      43             : 
      44             : 
      45             : /** \brief The interrupt initialization.
      46             :  *
      47             :  * The interrupt uses the signalfd() function to obtain a way to listen on
      48             :  * incoming Unix signals.
      49             :  *
      50             :  * Specifically, it listens on the SIGINT signal, which is the equivalent
      51             :  * to the Ctrl-C.
      52             :  *
      53             :  * \param[in] c  The cluck server we are listening for.
      54             :  */
      55          25 : interrupt::interrupt(cluckd * c)
      56             :     : signal(SIGINT)
      57          25 :     , f_cluckd(c)
      58             : {
      59          25 :     unblock_signal_on_destruction();
      60          25 :     set_name("interrupt");
      61          25 : }
      62             : 
      63             : 
      64          25 : interrupt::~interrupt()
      65             : {
      66          25 : }
      67             : 
      68             : 
      69             : /** \brief Call the stop function of the cluckd object.
      70             :  *
      71             :  * When this function is called, the signal was received and thus we are
      72             :  * asked to quit as soon as possible.
      73             :  */
      74           1 : void interrupt::process_signal()
      75             : {
      76             :     // we simulate the STOP, so pass 'false' (i.e. not quitting)
      77             :     //
      78           1 :     f_cluckd->stop(false);
      79           1 : }
      80             : 
      81             : 
      82             : 
      83             : } // namespace cluck_daemon
      84             : // vim: ts=4 sw=4 et

Generated by: LCOV version 1.14

Snap C++ | List of projects | List of versions