ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/repos/Spectre2/Spectre2.cpp
(Generate patch)

Comparing Spectre2/Spectre2.cpp (file contents):
Revision 402 by douglas, 2004-12-29T22:38:37-08:00 vs.
Revision 408 by douglas, 2004-12-31T01:08:16-08:00

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines