Main Page   Modules   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

MyDaemon Class Reference

Inheritance diagram for MyDaemon:

dsDaemon List of all members.

Public Methods

 MyDaemon ()
virtual int init_globals ()
virtual pid_t fork_child ()
virtual void shutdown_child ()
virtual int reinit ()
void kill_running ()

Protected Methods

void processPidFile ()
void addChild (pid_t npid)
void removeChild (pid_t npid)
int waitForFreeSlot (pid_t pid)

Friends

void daemonize (dsDaemon *sd, int options=0)
void dsSafeSleep (int secs, int nsecs=0)
int DaemonFlags (char *str)
void SIGCHLD_hdl (int sig)
void SIGANY_hdl (int sig)
void SIGINT_hdl (int sig)

Constructor & Destructor Documentation

MyDaemon::MyDaemon   [inline]
 


Member Function Documentation

void dsDaemon::addChild pid_t    npid [protected, inherited]
 

pid_t dsDaemon::fork_child   [virtual, inherited]
 

fork child. Default function increase child counter and then fork. It's better to call return dsDaemon::fork_child() at the end of overloaded function. if overloaded function returns -1 (fork error) child will not be intialised.

Reimplemented in dsHttpDaemon.

int dsDaemon::init_globals   [virtual, inherited]
 

Perform tasks after daemon detach, but before first fork all file handlers is closed to this point.

Reimplemented in dsHttpDaemon.

void dsDaemon::kill_running   [inherited]
 

read pid file and kill running instance

void dsDaemon::processPidFile   [protected, inherited]
 

int dsDaemon::reinit   [virtual, inherited]
 

Function to call from SIGHUP handler. Week point use it with care.

void dsDaemon::removeChild pid_t    npid [protected, inherited]
 

void dsDaemon::shutdown_child   [virtual, inherited]
 

This function called when child terminated wether by SIGTERM or normally

Reimplemented in dsHttpDaemon.

int dsDaemon::waitForFreeSlot pid_t    pid [protected, inherited]
 

Waits for free slot in child array, and returns number of found slot


Friends And Related Function Documentation

int DaemonFlags char *    str [friend, inherited]
 

Convert text reperesentation of daemon file into binary flags

void daemonize dsDaemon   sd,
int    options = 0
[friend, inherited]
 

Perform basic system tasks to become a daemon: close all handlers, allocate new process group and detach

  • sd pointer to dsDaemon object
  • options daemon flags

void dsSafeSleep int    secs,
int    nsecs = 0
[friend, inherited]
 

safe sleep: implement sleep by nanosleep or select timer (TODO), instead of using SIGALARM or sleep() to avoid possible interference with user application

void SIGANY_hdl int    sig [friend, inherited]
 

void SIGCHLD_hdl int    sig [friend, inherited]
 

void SIGINT_hdl int    sig [friend, inherited]
 


The documentation for this class was generated from the following file:
Generated on Mon May 16 18:27:00 2005 for libdms4 by doxygen1.3-rc2