ldb: version 1.5.2
[Samba.git] / lib / util / become_daemon.h
blobd697a689cdc03010ebd6184f6645fde320d39018
1 /*
2 Unix SMB/CIFS implementation.
3 Samba utility functions
4 Copyright (C) Andrew Tridgell 1992-1998
5 Copyright (C) Jeremy Allison 2001-2002
6 Copyright (C) Simo Sorce 2001
7 Copyright (C) Jim McDonough (jmcd@us.ibm.com) 2003.
8 Copyright (C) James J Myers 2003
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 3 of the License, or
13 (at your option) any later version.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program. If not, see <http://www.gnu.org/licenses/>.
24 #ifndef _BECOME_DAEMON_H
25 #define _BECOME_DAEMON_H
27 #include <stdbool.h>
29 /**
30 * @file become_daemon.h
32 * @brief Utilities for demonising
35 /**
36 * @brief Close the low 3 file descriptors and open /dev/null in their place
38 * @param[in] stdin_too Should stdin be closed?
39 * @param[in] stdout_too Should stdout be closed?
40 * @param[in] stderr_too Should stderr be closed?
41 **/
42 void close_low_fds(bool stdin_too, bool stdout_too, bool stderr_too);
44 /**
45 * @brief Become a daemon, optionally discarding the controlling terminal
47 * @param[in] do_fork Should the process fork?
48 * @param[in] no_session Don't start a new session
49 * @param[in] log_stdour Should stdout be closed?
50 **/
51 void become_daemon(bool do_fork, bool no_session, bool log_stdout);
53 /**
54 * @brief Exit daemon and log an error message at ERR level
56 * Optionally report failure to systemd if systemd integration is
57 * enabled.
59 * @param[in] msg Message to log, generated from error if NULL
60 * @param[in] error Errno of error that occurred
61 **/
62 void exit_daemon(const char *msg, int error);
64 /**
65 * @brief Log at ERR level that the daemon is ready to serve connections
67 * Optionally report status to systemd if systemd integration is enabled.
69 * @param[in] daemon Name of daemon to include it message
70 **/
71 void daemon_ready(const char *daemon);
73 /**
74 * @brief Log at ERR level the specified daemon status
76 * For example if it is not ready to serve connections and is waiting
77 * for some event to happen.
79 * Optionally report status to systemd if systemd integration is enabled.
81 * @param[in] daemon Name of daemon to include it message
82 * @param[in] msg Message to log
83 **/
84 void daemon_status(const char *daemon, const char *msg);
86 #endif /* _BECOME_DAEMON_H */