-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtest.cpp
More file actions
51 lines (40 loc) · 930 Bytes
/
test.cpp
File metadata and controls
51 lines (40 loc) · 930 Bytes
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
#include <iostream>
#include "Daemonize.hpp"
using namespace std;
USING_NAMESPACE_SWITCHTOOL
void hand1(int)
{
cout << "==INT" << endl;
}
void hand2(int)
{
cout << "==TERM" << endl;
}
void hand3(int)
{
cout << "==QUIT" << endl;
}
int main(void)
{
#ifndef DAEMONIZE_NO_BOOST
DaemonizeSingleton& daemon = DaemonizeSingleton::get_mutable_instance();
#else
Daemonize daemon;
#endif // DAEMONIZE_NO_BOOST
daemon.BaseDir() = "/tmp/aa/bb/cc";
daemon.PidFile() = "test.pid";
//daemon.SetDefaultBaseDir();
//daemon.SetDefaultPidFile();
cout << "SetDaemonize = " << daemon.SetDaemonize() << endl;
cout << "CheckPidFile = " << daemon.CheckPidFile() << endl;
cout << "WritePidFile = " << daemon.WritePidFile() << endl;
daemon.RegistSigHandler(SIGINT, hand1);
daemon.RegistSigHandler(SIGTERM, hand2);
daemon.RegistSigHandler(SIGQUIT, hand3);
daemon.SetSigHandler();
while (1)
{
sleep(60);
break;
}
}