A class for deamonising 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... | |
A class for deamonising the calling process.
Deamonisation includes fork()ing, detaching from the controlling terminal, setting the process umask, etc. The windows implementation does nothing.
|
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.
References G::Process::cd(), G::NewProcess::fork(), and G::NewProcess::Parent.
Referenced by detach().
|
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.
References G::PidFile::check(), and detach().