#include <daemon_unix.h>
Collaboration diagram for OmniEvents::DaemonImpl:

Public Methods | |
| DaemonImpl () | |
| ~DaemonImpl () | |
| void | tracefile (const char *val) |
| Set _tracefile. More... | |
| void | pidfile (const char *val) |
| Set _pidfile. More... | |
| void | foreground (bool val) |
| Set _foreground. More... | |
| void | initialize (int &, char **&) |
| Does nothing on Unix. More... | |
| void | daemonize () |
| Puts the current process into the background. More... | |
| void | runningOk () |
| Called to signal that all startup operations have completed OK. More... | |
| void | shutdown (int status) |
| Exit handler called (indirectly) by on_exit() - shuts down the daemon. More... | |
Static Public Methods | |
| void | log (const char *message) |
| Callback, used as a parameter to omniORB::setLogFunction(). More... | |
Public Attributes | |
| char * | _tracefile |
| The tracefile name (if any). More... | |
| bool | _foreground |
| TRUE for debug mode (run in foreground). More... | |
| char * | _pidfile |
| The pidfile name (if any). More... | |
| int | _pipe [2] |
| Unnamed pipe for child->parent comms. More... | |
| bool | _havePidfile |
| Is there a pidfile for us to clean up? More... | |
| bool | _haveParent |
| Is there a parent for us to clean up? More... | |
| bool | _haveSyslog |
| Should we close syslog before quitting? More... | |
Static Public Attributes | |
| DaemonImpl | _inst |
Private Methods | |
| void | fork () |
| Performs the actual fork. More... | |
| void | redirectStreamsTo (const char *filename) |
| Redirect stdout & stderr to filename. More... | |
| int | openFileFor (int fd, const char *filename, int flags) |
| Opens a (new?) file called 'filename' for writing, and uses it to hijack stream 'fd'. More... | |
| void | checkPidfileOrShutdown () |
| If pidfile exists & contains a running process then shutdown() (Unix). More... | |
| void | writePidfile () |
| int | waitForChild () |
| Called by the parent process (Unix). More... | |
| void | notifyParent (int status) |
| Tells the parent to exit with the given status (Unix). More... | |
Features: pidfile support, forking, redirect omniORB trace to syslog (or tracefile).
Definition at line 37 of file daemon_unix.h.
|
|
Definition at line 119 of file daemon_unix.cc. |
|
|
Definition at line 122 of file daemon_unix.cc. References _pidfile, and _tracefile. |
|
|
If pidfile exists & contains a running process then shutdown() (Unix). Also shuts down if pidfile is inaccessible. Definition at line 298 of file daemon_unix.cc. References _pidfile, and STRERR_FILE_LINE. Referenced by daemonize(). |
|
|
Puts the current process into the background. Redirects the omniORB log output to syslog (or 'tracefile', if it is set). Definition at line 158 of file daemon_unix.cc. References _foreground, _haveSyslog, _tracefile, checkPidfileOrShutdown(), fork(), PACKAGE_NAME, redirectStreamsTo(), omniORB::setLogFunction(), OmniEvents::shutdown2(), STRERR_FILE_LINE, and writePidfile(). Referenced by OmniEvents::Daemon::daemonize(). |
|
|
Set _foreground.
Definition at line 137 of file daemon_unix.cc. References _foreground. Referenced by OmniEvents::Daemon::foreground(). |
|
|
Performs the actual fork.
Definition at line 378 of file daemon_unix.cc. References _haveParent, _pipe, PIPE_READ, PIPE_WRITE, STRERR_FILE_LINE, and waitForChild(). Referenced by daemonize(). |
|
||||||||||||
|
Does nothing on Unix.
Definition at line 152 of file daemon_unix.cc. |
|
|
Callback, used as a parameter to omniORB::setLogFunction(). WARNING: Performs magic! Sets the syslog priority to LOG_INFO or LOG_ERR depending upon whether the message string starts with 'omniEvents! ' or 'omniEvents: '. Definition at line 265 of file daemon_unix.cc. References _haveParent. |
|
|
Tells the parent to exit with the given status (Unix).
Definition at line 477 of file daemon_unix.cc. References _pipe, PIPE_WRITE, and STRERR_FILE_LINE. |
|
||||||||||||||||
|
Opens a (new?) file called 'filename' for writing, and uses it to hijack stream 'fd'.
Definition at line 446 of file daemon_unix.cc. Referenced by redirectStreamsTo(). |
|
|
Set _pidfile.
Definition at line 143 of file daemon_unix.cc. Referenced by OmniEvents::Daemon::pidfile(). |
|
|
Redirect stdout & stderr to filename. Also redirects stdin from /dev/null Definition at line 426 of file daemon_unix.cc. References openFileFor(), STDIN_FILENO, STDOUT_FILENO, and STRERR_FILE_LINE. |
|
|
Called to signal that all startup operations have completed OK. Notifies the parent process and redirects stdout & stderr to 'tracefile' (or else /dev/null). Definition at line 215 of file daemon_unix.cc. References _haveParent, notifyParent(), PACKAGE_NAME, and redirectStreamsTo(). Referenced by OmniEvents::Daemon::runningOk(). |
|
|
Exit handler called (indirectly) by on_exit() - shuts down the daemon. Deletes pidfile (if we have one), notifies the parent (if we have one). Definition at line 236 of file daemon_unix.cc. References _haveParent, _havePidfile, _haveSyslog, _pidfile, notifyParent(), and STRERR_FILE_LINE. Referenced by OmniEvents::shutdown0(), OmniEvents::shutdown2(), and OmniEvents::Daemon::~Daemon(). |
|
|
Set _tracefile.
Definition at line 131 of file daemon_unix.cc. References _tracefile. Referenced by OmniEvents::Daemon::tracefile(). |
|
|
Called by the parent process (Unix). Waits for the child to return an exit status. The status is usually '0' - indicating that the daemon has started successfully. Definition at line 460 of file daemon_unix.cc. References _pipe, PIPE_READ, and STRERR_FILE_LINE. Referenced by fork(). |
|
|
Definition at line 353 of file daemon_unix.cc. References _havePidfile, and _pidfile. Referenced by daemonize(). |
|
|
TRUE for debug mode (run in foreground).
Definition at line 43 of file daemon_unix.h. Referenced by OmniEvents::Daemon::Daemon(), daemonize(), and foreground(). |
|
|
Is there a parent for us to clean up?
Definition at line 47 of file daemon_unix.h. Referenced by OmniEvents::Daemon::Daemon(), fork(), log(), runningOk(), and shutdown(). |
|
|
Is there a pidfile for us to clean up?
Definition at line 46 of file daemon_unix.h. Referenced by OmniEvents::Daemon::Daemon(), shutdown(), and writePidfile(). |
|
|
Should we close syslog before quitting?
Definition at line 48 of file daemon_unix.h. Referenced by OmniEvents::Daemon::Daemon(), daemonize(), and shutdown(). |
|
|
Definition at line 40 of file daemon_unix.h. |
|
|
The pidfile name (if any).
Definition at line 44 of file daemon_unix.h. Referenced by checkPidfileOrShutdown(), OmniEvents::Daemon::Daemon(), shutdown(), writePidfile(), and ~DaemonImpl(). |
|
|
Unnamed pipe for child->parent comms.
Definition at line 45 of file daemon_unix.h. Referenced by OmniEvents::Daemon::Daemon(), fork(), notifyParent(), and waitForChild(). |
|
|
The tracefile name (if any).
Definition at line 42 of file daemon_unix.h. Referenced by OmniEvents::Daemon::Daemon(), daemonize(), tracefile(), and ~DaemonImpl(). |
1.2.15