Rudiments
/home/dmuse/src/rudiments/include/rudiments/daemonprocess.h
00001 // Copyright (c) 1999-2002 David Muse
00002 // See the COPYING file for more information.
00003 
00004 #ifndef RUDIMENTS_DAEMONPROCESS_H
00005 #define RUDIMENTS_DAEMONPROCESS_H
00006 
00007 #include <rudiments/private/daemonprocessincludes.h>
00008 
00009 #ifdef RUDIMENTS_NAMESPACE
00010 namespace rudiments {
00011 #endif
00012 
00013 class daemonprocessprivate;
00014 
00023 class RUDIMENTS_DLLSPEC daemonprocess {
00024         public:
00025 
00027                 daemonprocess();
00028 
00030                 virtual ~daemonprocess();
00031 
00035                 static int64_t  checkForPidFile(const char *filename);
00036 
00044                 static bool     createPidFile(const char *filename,
00045                                                 mode_t permissions);
00046 
00053                 bool    detach() const;
00054 
00064                 int32_t runAsUser(const char *username) const;
00065 
00075                 int32_t runAsGroup(const char *groupname) const;
00076 
00081                 int32_t runAsUserId(uid_t uid) const;
00082 
00087                 int32_t runAsGroupId(gid_t gid) const;
00088 
00089 
00092                 static  void    handleShutDown(
00093                                         void (*shutdownfunction)(int32_t));
00094 
00097                 static  void    handleCrash(void (*crashfunction)(int32_t));
00098 
00103                 static  void    waitForChildren();
00104 
00111                 static  void    dontWaitForChildren();
00112 
00113         #include <rudiments/private/daemonprocess.h>
00114 
00115 };
00116 
00117 #ifdef RUDIMENTS_NAMESPACE
00118 }
00119 #endif
00120 
00121 #endif