4 |
|
// |
5 |
|
// $Id$ |
6 |
|
|
7 |
– |
#include "SignalHandler.hpp" |
7 |
|
#include "Mounter.hpp" |
8 |
|
#include "Unmounter.hpp" |
9 |
|
#include "Matcher/Matcher.hpp" |
16 |
|
{ |
17 |
|
#include <sys/types.h> |
18 |
|
#include <unistd.h> |
19 |
+ |
#include <signal.h> |
20 |
|
} |
21 |
|
|
22 |
|
struct Spectre2Command : public app::Application |
50 |
|
} |
51 |
|
} spectre; |
52 |
|
|
53 |
+ |
extern "C" |
54 |
+ |
{ |
55 |
+ |
void reload(int signal, ::siginfo_t* info, void* uap); |
56 |
+ |
void stop(int signal, ::siginfo_t* info, void* uap); |
57 |
+ |
} |
58 |
+ |
|
59 |
|
Spectre2::Spectre2(const ext::String& config, const ext::String& pid) : pid(pid) |
60 |
|
{ |
61 |
|
{ |
67 |
|
|
68 |
|
Mounter mounter(config); |
69 |
|
Unmounter unmounter(config); |
70 |
< |
Daemon* daemons[] = { static_cast<Daemon*>(&mounter), static_cast<Daemon*>(&unmounter) }; |
71 |
< |
SignalHandler handler(daemons, sizeof (daemons) / sizeof (*daemons)); |
70 |
> |
|
71 |
> |
daemons.InsertLast(static_cast<Daemon*>(&mounter)); |
72 |
> |
daemons.InsertLast(static_cast<Daemon*>(&unmounter)); |
73 |
> |
|
74 |
> |
{ |
75 |
> |
struct ::sigaction action; |
76 |
> |
|
77 |
> |
action.sa_sigaction = reload; |
78 |
> |
action.sa_flags = SA_SIGINFO; |
79 |
> |
|
80 |
> |
api::Posix::CheckError(::sigemptyset(&action.sa_mask)); |
81 |
> |
api::Posix::CheckError(::sigaction(SIGHUP, &action, NULL)); |
82 |
> |
|
83 |
> |
action.sa_sigaction = stop; |
84 |
> |
|
85 |
> |
api::Posix::CheckError(::sigaction(SIGTERM, &action, NULL)); |
86 |
> |
} |
87 |
|
} |
88 |
|
|
89 |
|
Spectre2::~Spectre2() |
93 |
|
|
94 |
|
ext::String Spectre2::program(api::GetExecutablePath().GetName()); |
95 |
|
bool Spectre2::debug(false); |
96 |
+ |
ext::Vector<Daemon*> Spectre2::daemons; |
97 |
+ |
|
98 |
+ |
extern "C" |
99 |
+ |
{ |
100 |
+ |
void reload(int signal, ::siginfo_t* info, void* uap) |
101 |
+ |
{ |
102 |
+ |
_mforeach (ext::Vector<Daemon*>, daemon, Spectre2::daemons) (*daemon)->reload(); |
103 |
+ |
} |
104 |
+ |
|
105 |
+ |
void stop(int signal, ::siginfo_t* info, void* uap) |
106 |
+ |
{ |
107 |
+ |
_mforeach (ext::Vector<Daemon*>, daemon, Spectre2::daemons) (*daemon)->stop(); |
108 |
+ |
} |
109 |
+ |
} |