Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members

CArchDaemonUnix Class Reference

Unix implementation of IArchDaemon. More...

#include <CArchDaemonUnix.h>

Inherits CArchDaemonNone.

Inheritance diagram for CArchDaemonUnix:

Inheritance graph
[legend]
Collaboration diagram for CArchDaemonUnix:

Collaboration graph
[legend]
List of all members.

Public Member Functions

virtual int daemonize (const char *name, DaemonFunc func)
 Daemonize the process.

Detailed Description

Unix implementation of IArchDaemon.

Definition at line 24 of file CArchDaemonUnix.h.


Member Function Documentation

int CArchDaemonUnix::daemonize const char *  name,
DaemonFunc  func
[virtual]
 

Daemonize the process.

Daemonize. Throw XArchDaemonFailed on error. name is the name of the daemon. Once daemonized, func is invoked and daemonize returns when and what it does.

Exactly what happens when daemonizing depends on the platform.

  • unix: Detaches from terminal. func gets passed one argument, the name passed to daemonize().
  • win32: Becomes a service. Argument 0 is the name of the service and the rest are the arguments passed to StartService(). func is only called when the service is actually started. func must call CArchMiscWindows::runDaemon() to finally becoming a service. The runFunc function passed to runDaemon() must call CArchMiscWindows::daemonRunning(true) when it enters the main loop (i.e. after initialization) and CArchMiscWindows::daemonRunning(false) when it leaves the main loop. The stopFunc function passed to runDaemon() is called when the daemon must exit the main loop and it must cause runFunc to return. func should return what runDaemon() returns. func or runFunc can call CArchMiscWindows::daemonFailed() to indicate startup failure.

Reimplemented from CArchDaemonNone.

Definition at line 39 of file CArchDaemonUnix.cpp.


The documentation for this class was generated from the following files:
Generated on Fri Nov 6 00:21:17 2009 for synergy-plus by  doxygen 1.3.9.1