/usr/share/doc/libbobcat4-dev/man/signal.3.html is in libbobcat-dev 4.01.03-2ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 | <!DOCTYPE html><html><head>
<meta charset="UTF-8">
<title>FBB::Signal</title>
<style type="text/css">
figure {text-align: center;}
img {vertical-align: center;}
</style>
<link rev="made" href="mailto:Frank B. Brokken: f.b.brokken@rug.nl">
</head>
<body text="#27408B" bgcolor="#FFFAF0">
<hr>
<h1>FBB::Signal</h1>
<h2>libbobcat-dev_4.01.03-x.tar.gz</h2>
<h2>2005-2015</h2>
<!DOCTYPE html><html><head>
<meta charset="UTF-8">
<style type="text/css">
figure {text-align: center;}
img {vertical-align: center;}
figure {text-align: center;}
img {vertical-align: center;}
</style>
<link rev="made" href="mailto:Frank B. Brokken: f.b.brokken@rug.nl">
</head>
<body text="#27408B" bgcolor="#FFFAF0">
<hr>
<h1></h1>
<!DOCTYPE html><html><head>
<meta charset="UTF-8">
<title>FBB::Signal(3bobcat)</title>
<style type="text/css">
figure {text-align: center;}
img {vertical-align: center;}
figure {text-align: center;}
img {vertical-align: center;}
figure {text-align: center;}
img {vertical-align: center;}
</style>
<link rev="made" href="mailto:Frank B. Brokken: f.b.brokken@rug.nl">
</head>
<body text="#27408B" bgcolor="#FFFAF0">
<hr>
<h1>FBB::Signal(3bobcat)</h1>
<h2>libbobcat-dev_4.01.03-x.tar.gz signal handler</h2>
<h2>2005-2015</h2>
<p>
<h2>NAME</h2>FBB::Signal - Signal Handler
<p>
<h2>SYNOPSIS</h2>
<strong>#include <bobcat/signal></strong><br>
Linking option: <em>-lbobcat</em>
<p>
<h2>DESCRIPTION</h2>
<p>
Signals have the well known drawback that signals arrive free of
context. E.g., assume a program runs a flow control loop like this:
<pre>
void Class::run()
{
while (d_continue)
handleTasks();
cleanup();
}
</pre>
then if the program needs to recognize a termination signal then the
typical signal handler looks like this:
<pre>
void signalHandler(int signal)
{
// perform required actions
}
</pre>
Since the <em>signalHandler</em> is called asynchronically, there is no context
available, and the usual way of communicating between objects and signal
handlers is via static variables, like this:
<pre>
// declared as static bool s_continue;
bool Class::s_continue = true;
void Class::run()
{
while (s_continue)
handleTasks();
cleanup();
}
// declared as static void signalHander(int signal);
void Class::signalHandler(int signal)
{
s_continue = false;
}
</pre>
The class <em>Signal</em> allows the signal handler to operate in the context
of a class. The advantage of this is that static data members are no longer
required and that the signal may be used to control data members of individual
objects.
<p>
The signal is now handled by an object, whose class must define a member
<pre>
void signalHandler(size_t signum) override;
</pre>
and this function is responsible for handling the received signal. Since
it is a member function it may affect its object's local variables and it may
call its object's member functions. Static data members are not required
anymore (see below for an example).
<p>
Note that, as the signal may arrive at unpredicable times data members
that can be modified by <em>signalHandler</em> should be declared using the
<em>volatile</em> modifier. Moreover, data that can be modified by
the <em>signalHandler</em> member and by other class members should be protected
by <em>mutexes</em> (cf. the <strong>C++-11</strong> class <em>std::mutex</em> or
<strong>pthread_mutex_lock</strong>(3posix)).
<p>
<h2>NAMESPACE</h2>
<strong>FBB</strong><br>
All constructors, members, operators and manipulators, mentioned in this
man-page, are defined in the namespace <strong>FBB</strong>.
<p>
<h2>INHERITS FROM</h2>
<em>Signal</em> is not derived from other classes, but the classes for which
signals must be handled by <em>Signal</em> must themselves publicly be derived from
the class <em>FBB::SignalHandler</em> and must implement a member
<pre>
void signalHandler(size_t signum) override;
</pre>
handling the received signal.
<p>
<h2>CONSTRUCTORS AND OVERLOADED OPERATORS</h2>
<em>Signal</em> is defined as a <em>singleton</em>, and does not offer public or
protected constructors, nor does it offer overloaded operators.
<p>
<h2>STATIC MEMBER FUNCTION</h2>
<ul>
<li> <strong>static Signal &instance()</strong>:<br><br>
This static member can be used to access a reference to the program's
single <em>Signal</em> object.
</ul>
<p>
<h2>MEMBER FUNCTIONS</h2>
All of <em>Signal</em>'s member functions can only be called through a
reference to the program's <em>Signal</em> object, returning a reference to the
program's single <em>Signal</em> object:
<ul>
<li> <strong>void add(size_t signum, SignalHandler &object)</strong>:<br><br>
<em>SignalHandler object</em> is activated on arrival of signal
<em>signum</em>. If multiple <em>SignalHandler</em> objects must be called then
multiple <em>Signal::add</em> calls can be provided, and the various
<em>SignalHandler::signalHandler</em> members are called in the same
sequence as their respective <em>Signal::add</em> calls. If one of the
earlier <em>signalHandler</em> members terminates the program then later
<em>signalHandler</em> members are not activated anymore. If
<em>Signal::add</em> is called by, e.g., an object's constructor, then its
destructor should call <em>Signal::remove</em> to prevent the object's
signal handler from being called after its destruction.
<li> <strong>void remove(size_t signum, SignalHandler &object)</strong>:<br><br>
<em>SignalHandler object</em> for signal <em>signum</em> is removed from the
<em>Signal</em> object. It is the responsibility of <em>object</em> to
deregister itself from <em>Signal</em> just before <em>object</em> goes out of
scope. Objects can only deregister themselves if they've previously
registered themselves using <em>add</em>.
<li> <strong>void ignore(size_t signum)</strong>:<br><br>
Any previously installed <em>SignalHandler</em> object is no longer
activated on arrival of signal <em>signum</em>. In addition, if possible,
signal <em>signum</em> is completely ignored (some signals cannot be
caught, blocked, of ignored, like <em>SIGKILL</em> and <em>SIGSTOP</em>
(cf. <strong>signal</strong>(7))).
<li> <strong>void reset(size_t signum)</strong>:<br><br>
Any previously installed <em>SignalHandler</em> object is no longer
activated on arrival of signal <em>signum</em>. In addition, the default
action the program takes on arrival of signal <em>signum</em> is
reinstalled (cf. <strong>signal</strong>(7)).
</ul>
<p>
If the <em>signum</em> value that is passed to <em>Signal</em>'s members is not a
defined signal value, then an <strong>FBB::Exception</strong> exception is thrown.
<p>
<h2>EXAMPLE</h2>
<pre>
#include <sys/types.h>
#include <unistd.h>
#include <iostream>
#include "../signal"
class SignalDemo: public FBB::SignalHandler
{
volatile size_t d_signal;
volatile bool d_continue;
pid_t d_pid;
public:
SignalDemo();
void run();
private:
void signalHandler(size_t signum) override;
};
using namespace std;
using namespace FBB;
SignalDemo::SignalDemo()
:
d_signal(0),
d_continue(true),
d_pid(getpid())
{}
void SignalDemo::run()
{
while (d_continue)
{
cout << "Send a SIGINT or SIGTERM... to process " << d_pid << endl;
sleep(1);
}
cout << "Ending `run' after receiving signal " << d_signal << endl;
}
void SignalDemo::signalHandler(size_t signal)
{
if (signal == SIGINT)
cout << "Process " << d_pid << " received SIGINT" << endl;
else if (signal == SIGTERM)
{
cout << "Process " << d_pid << " received SIGTERM" << endl;
d_signal = SIGTERM;
d_continue = false;
}
}
int main()
{
SignalDemo signalDemo;
Signal::instance().add(SIGINT, signalDemo);
Signal::instance().add(SIGTERM, signalDemo);
signalDemo.run();
}
</pre>
<p>
<h2>FILES</h2>
<em>bobcat/signal</em> - defines the class interface
<p>
<h2>SEE ALSO</h2>
<strong>bobcat</strong>(7), <strong>pthread_mutex_lock</strong>(3posix), <strong>signal</strong>(7),<br>
and the <strong>C++-11</strong> class <em>std::mutex</em>.
<p>
<h2>BUGS</h2>
None Reported.
<p>
<h2>DISTRIBUTION FILES</h2>
<ul>
<li> <em>bobcat_4.01.03-x.dsc</em>: detached signature;
<li> <em>bobcat_4.01.03-x.tar.gz</em>: source archive;
<li> <em>bobcat_4.01.03-x_i386.changes</em>: change log;
<li> <em>libbobcat1_4.01.03-x_*.deb</em>: debian package holding the
libraries;
<li> <em>libbobcat1-dev_4.01.03-x_*.deb</em>: debian package holding the
libraries, headers and manual pages;
<li> <em>http://sourceforge.net/projects/bobcat</em>: public archive location;
</ul>
<p>
<h2>BOBCAT</h2>
Bobcat is an acronym of `Brokken's Own Base Classes And Templates'.
<p>
<h2>COPYRIGHT</h2>
This is free software, distributed under the terms of the
GNU General Public License (GPL).
<p>
<h2>AUTHOR</h2>
Frank B. Brokken (<strong>f.b.brokken@rug.nl</strong>).
<p>
|