snaplock: snaplock_interrupt.cpp Source File

snaplock  1.7.14
The multi-computer lock service.
snaplock_interrupt.cpp
Go to the documentation of this file.
1 /*
2  * Text:
3  * snaplock/src/snaplock_interrupt.cpp
4  *
5  * Description:
6  * A daemon to synchronize processes between any number of computers
7  * by blocking all of them but one.
8  *
9  * The interrupt implementation listens for the Ctrl-C or SIGINT Unix
10  * signal. When the signal is received, it calls the stop function
11  * of the snaplock object to simulate us receiving a STOP message.
12  *
13  * License:
14  * Copyright (c) 2016-2019 Made to Order Software Corp. All Rights Reserved
15  *
18  *
19  * Permission is hereby granted, free of charge, to any person obtaining a
20  * copy of this software and associated documentation files (the
21  * "Software"), to deal in the Software without restriction, including
22  * without limitation the rights to use, copy, modify, merge, publish,
23  * distribute, sublicense, and/or sell copies of the Software, and to
24  * permit persons to whom the Software is furnished to do so, subject to
25  * the following conditions:
26  *
27  * The above copyright notice and this permission notice shall be included
28  * in all copies or substantial portions of the Software.
29  *
30  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
31  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
32  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
33  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
34  * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
35  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
36  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
37  */
38 
39 
40 // ourselves
41 //
42 #include "snaplock.h"
43 
44 // our lib
45 //
46 #include <snapwebsites/log.h>
47 
48 
49 namespace snaplock
50 {
51 
72  : snap_signal(SIGINT)
73  , f_snaplock(sl)
74 {
75  unblock_signal_on_destruction();
76  set_name("snaplock interrupt");
77 }
78 
79 
86 {
87  // we simulate the STOP, so pass 'false' (i.e. not quitting)
88  //
89  f_snaplock->stop(false);
90 }
91 
92 
93 }
94 // snaplock namespace
95 // vim: ts=4 sw=4 et
virtual void process_signal() override
Call the stop function of the snaplock object.
snaplock_interrupt(snaplock *sl)
The interrupt initialization.
virtual void stop(bool quitting) override
Called whenever we receive the STOP command or equivalent.
Definition: snaplock.cpp:2126

This document is part of the Snap! Websites Project.

Copyright by Made to Order Software Corp.

Syndicate content

Snap! Websites
An Open Source CMS System in C++

Contact Us Directly