Protium
Math and Design Features
Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerator
Friends
Macros
Pages
Daemon.h
Go to the documentation of this file.
1
#ifndef Protium_Daemon_h_
2
#define Protium_Daemon_h_
3
4
namespace
Protium{
5
namespace
Threads{
6
7
8
class
Daemon
{
9
private
:
10
pid_t
pid
;
11
pid_t
sid
;
12
public
:
13
Daemon
(){
14
pid
=0;
15
}
16
17
void
start
(){
18
19
pid
=fork();
20
}
21
22
bool
isGood
(){
23
return
(
pid
!=-1) && (
pid
!=0);
24
}
25
26
void
killGrandParent
(){
27
exit(EXIT_SUCCESS);
28
}
29
30
void
setFileMask
(){
31
umask(0);
32
}
33
void
setSID
(){
34
sid
=setsid();
35
if
(
sid
<0)
36
exit(EXIT_FAILURE);
37
}
38
39
void
setToRootFile
(){
40
if
( chdir(
"/"
)<0){
41
exit(EXIT_FAILURE);
42
}
43
}
44
45
void
closeFileDescriptors
(){
46
close(STDIN_FILENO);
47
close(STDOUT_FILENO);
48
close(STDERR_FILENO);
49
}
50
51
void
loop
(){
52
53
//schedule tasks and whatnot
54
}
55
};
56
}
57
}
58
59
60
#endif //File Guardian
Protium::Threads::Daemon::loop
void loop()
Definition:
Daemon.h:51
Protium::Threads::Daemon::setSID
void setSID()
Definition:
Daemon.h:33
Protium::Threads::Daemon::closeFileDescriptors
void closeFileDescriptors()
Definition:
Daemon.h:45
Protium::Threads::Daemon::Daemon
Daemon()
Definition:
Daemon.h:13
Protium::Threads::Daemon
Definition:
Daemon.h:8
Protium::Threads::Daemon::setFileMask
void setFileMask()
Definition:
Daemon.h:30
Protium::Threads::Daemon::isGood
bool isGood()
Definition:
Daemon.h:22
Protium::Threads::Daemon::start
void start()
Definition:
Daemon.h:17
Protium::Threads::Daemon::setToRootFile
void setToRootFile()
Definition:
Daemon.h:39
Protium::Threads::Daemon::sid
pid_t sid
Definition:
Daemon.h:11
Protium::Threads::Daemon::killGrandParent
void killGrandParent()
Definition:
Daemon.h:26
Protium::Threads::Daemon::pid
pid_t pid
Definition:
Daemon.h:10
Source
kjw_software
Protium
Threads
Daemon.h
Generated on Thu Oct 9 2014 07:12:43 for Protium by
1.8.6