fgms 0.11.8
The
FlightGear MultiPlayer Server
project
daemon.hxx
Go to the documentation of this file.
1 /**
2  * @file daemon.hxx
3  * @author Oliver Schroeder
4  */
5 //
6 // This program is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU General Public License as
8 // published by the Free Software Foundation; either version 2 of the
9 // License, or (at your option) any later version.
10 //
11 // This program is distributed in the hope that it will be useful, but
12 // WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software
18 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, U$
19 //
20 // Copyright (C) 2006 Oliver Schroeder
21 //
22 
23 //////////////////////////////////////////////////////////////////////
24 //
25 // interface for the daemon-class
26 //
27 //////////////////////////////////////////////////////////////////////
28 
29 
30 #ifndef CDAEMON_HDR
31 #define CDAEMON_HDR
32 
33 #ifndef _MSC_VER
34 #include <sys/types.h>
35 #include <sys/stat.h>
36 #include <sys/signal.h>
37 #include <list>
38 #include <fcntl.h>
39 
40 using namespace std;
41 
42 /** @brief Implement everything necessary to become a daemon */
43 class cDaemon
44 {
45  /** @brief remember who we are */
46  static pid_t PidOfDaemon;
47 
48  /** @brief keep track of our children */
49  static list <pid_t> Children;
50 
51 public:
52  cDaemon();
53  ~cDaemon ();
54  static void SigHandler ( int SigType );
55  static int Daemonize (); // make us a daemon
56  static void KillAllChildren (); // kill our children and ourself
57  static void AddChild ( pid_t ChildsPid );
58  static int NumChildren ();
59 
60  /** @brief Return pid of deamon */
61  static int GetPid() { return PidOfDaemon; };
62 };
63 
64 #endif // #ifndef _MSC_VER
65 
66 
67 #endif
68 
69 
static list< pid_t > Children
keep track of our children
Definition: daemon.hxx:49
Implement everything necessary to become a daemon.
Definition: daemon.hxx:43
static int GetPid()
Return pid of deamon.
Definition: daemon.hxx:61
static pid_t PidOfDaemon
remember who we are
Definition: daemon.hxx:46