removed boost::filesystem dependency
[senf.git] / Utils / DaemonTools.hh
1 // $Id$
2 //
3 // Copyright (C) 2006 Stefan Bund <g0dil@senf.berlios.de>
4 //
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.
9 //
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.
14 //
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.
19
20 /** \file
21     \brief DaemonTools public header */
22
23 /** \defgroup process Process Management
24
25     Future features:
26
27     \li Daemon manager watching the real daemon. Auto-restart, when the daemon fails
28
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
31     
32     \li For this to be efficient, the daemon manager must be it's own executable (e.g. senf-launch)
33
34     \li auto-detect whether called from senf-launch or not
35
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
38     
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.
41
42     This collection of utilities provides help in managing daemon processes.
43
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.
47
48     \idea We might want to add other oft used utitlities: chroot(), setreuid(), pipes() / IPC ...
49  */
50
51 #ifndef HH_DaemonTools_
52 #define HH_DaemonTools_ 1
53
54 // Custom includes
55 #include <string>
56
57 //#include "DaemonTools.mpp"
58 ///////////////////////////////hh.p////////////////////////////////////////
59
60 namespace senf {
61
62     /// \addtogroup process
63     /// @{
64
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 */
72
73     /// @}
74 }
75
76 ///////////////////////////////hh.e////////////////////////////////////////
77 //#include "DaemonTools.cci"
78 //#include "DaemonTools.ct"
79 //#include "DaemonTools.cti"
80 //#include "DaemonTools.mpp"
81 #endif
82
83 \f
84 // Local Variables:
85 // mode: c++
86 // fill-column: 100
87 // c-file-style: "senf"
88 // indent-tabs-mode: nil
89 // ispell-local-dictionary: "american"
90 // compile-command: "scons -u test"
91 // comment-column: 40
92 // End: