VideoTools
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
G::Daemon Class Reference

A static interface for daemonising the calling process. More...

#include <gdaemon.h>

Static Public Member Functions

static void detach ()
 Detaches from the parent environment. More...
 
static void detach (PidFile &pid_file)
 An overload which allows for a delayed write of the new process-id to a file. More...
 

Detailed Description

A static interface for daemonising the calling process.

Daemonisation includes fork()ing, detaching from the controlling terminal, setting the process umask, etc. The windows implementation does nothing.

See Also
G::Process

Definition at line 42 of file gdaemon.h.

Member Function Documentation

void G::Daemon::detach ( )
static

Detaches from the parent environment.

This typically involves fork()ing, _exit()ing the parent, and calling setsid() in the child.

Definition at line 32 of file gdaemon_unix.cpp.

void G::Daemon::detach ( PidFile pid_file)
static

An overload which allows for a delayed write of the new process-id to a file.

A delayed write is useful for network daemons which open a listening port. A second instance of the process will fail on startup, and should not overwrite the pid file of the running server. In this situation PidFile::commit() should be called just before entering the event loop.

Throws PidFile::Error on error.

Definition at line 26 of file gdaemon_unix.cpp.


The documentation for this class was generated from the following files: