Rudiments
daemonprocess.h
1 // Copyright (c) 1999-2002 David Muse
2 // See the COPYING file for more information.
3 
4 #ifndef RUDIMENTS_DAEMONPROCESS_H
5 #define RUDIMENTS_DAEMONPROCESS_H
6 
7 #include <rudiments/private/daemonprocessincludes.h>
8 
9 #ifdef RUDIMENTS_NAMESPACE
10 namespace rudiments {
11 #endif
12 
13 class daemonprocessprivate;
14 
23 class RUDIMENTS_DLLSPEC daemonprocess {
24  public:
25 
27  daemonprocess();
28 
30  virtual ~daemonprocess();
31 
35  static int64_t checkForPidFile(const char *filename);
36 
44  static bool createPidFile(const char *filename,
45  mode_t permissions);
46 
53  bool detach() const;
54 
64  int32_t runAsUser(const char *username) const;
65 
75  int32_t runAsGroup(const char *groupname) const;
76 
81  int32_t runAsUserId(uid_t uid) const;
82 
87  int32_t runAsGroupId(gid_t gid) const;
88 
89 
92  static void handleShutDown(
93  void (*shutdownfunction)(int32_t));
94 
97  static void handleCrash(void (*crashfunction)(int32_t));
98 
103  static void waitForChildren();
104 
111  static void dontWaitForChildren();
112 
113  #include <rudiments/private/daemonprocess.h>
114 
115 };
116 
117 #ifdef RUDIMENTS_NAMESPACE
118 }
119 #endif
120 
121 #endif