3 // Copyright (C) 2006 Stefan Bund <g0dil@senf.berlios.de>
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 2 of the License, or
8 // (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the
17 // Free Software Foundation, Inc.,
18 // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 \brief DaemonTools public header */
23 /** \defgroup process Process Management
27 \li Daemon manager watching the real daemon. Auto-restart, when the daemon fails
29 \li Provide access to the config console indirectly via the daemon manager. This allows to
30 connect to the daemon manager console even if the app is not running
32 \li For this to be efficient, the daemon manager must be it's own executable (e.g. senf-launch)
34 \li auto-detect whether called from senf-launch or not
36 \li when daemon is running, the console is transparently forwarded to the daemon. The daemon
37 however can still access the daemon manager as a subgroup
39 \li No idea, whether this is sensible: Make the daemon manager completely self-contained (not
40 dependent on any external OS support) by providing our own log-file rotation support.
42 This collection of utilities provides help in managing daemon processes.
44 \idea A closeall()/closemost() function which is useful when starting child processes. We'll use
45 getrlimit to now the biggest filehandle and close all of em. closemost() takes a number of
46 file handles as arg and will keep those open.
48 \idea We might want to add other oft used utitlities: chroot(), setreuid(), pipes() / IPC ...
51 #ifndef HH_DaemonTools_
52 #define HH_DaemonTools_ 1
57 //#include "DaemonTools.mpp"
58 ///////////////////////////////hh.p////////////////////////////////////////
62 /// \addtogroup process
65 void daemonize(); ///< Make the current process a daemon process
66 /**< daemonize() will fork, detach from the controlling
67 terminal and start a new process group. */
68 void redirect_stdio(std::string const & path = "/dev/null"); ///< Redirect STDIN, STDOUT and STDERR
69 /**< All standard file-descriptors will be redirected to the
70 given path defaulting to <tt>/dev/null</tt>
71 \param[in] path path to redirect to */
76 ///////////////////////////////hh.e////////////////////////////////////////
77 //#include "DaemonTools.cci"
78 //#include "DaemonTools.ct"
79 //#include "DaemonTools.cti"
80 //#include "DaemonTools.mpp"
87 // c-file-style: "senf"
88 // indent-tabs-mode: nil
89 // ispell-local-dictionary: "american"
90 // compile-command: "scons -u test"