tests: rename logging test source
[gd/samba-autobuild/.git] / lib / util / become_daemon.h
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
9
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.
14
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.
19
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/>.
22 */
23
24 #ifndef _BECOME_DAEMON_H
25 #define _BECOME_DAEMON_H
26
27 #include <stdbool.h>
28
29 /**
30  * @file become_daemon.h
31  *
32  * @brief Utilities for demonising
33  */
34
35 /**
36  * @brief Enable or disable daemon status systemd notifications
37  *
38  * When samba runs as AD DC only the main 'samba' process has to
39  * notify systemd. Child processes started by the main 'samba', like
40  * smbd and winbindd should call this function to disable sd_notify()
41  * calls.
42  *
43  * @param[in] enable True to enable notifications, false to disable
44 **/
45 void daemon_sd_notifications(bool enable);
46
47 /**
48  * @brief Become a daemon, optionally discarding the controlling terminal
49  *
50  * @param[in] do_fork Should the process fork?
51  * @param[in] no_session Don't start a new session
52  * @param[in] log_stdour Should stdout be closed?
53 **/
54 void become_daemon(bool do_fork, bool no_session, bool log_stdout);
55
56 /**
57  * @brief Exit daemon and log an error message at ERR level
58  *
59  * Optionally report failure to systemd if systemd integration is
60  * enabled.
61  *
62  * @param[in] msg Message to log, generated from error if NULL
63  * @param[in] error Errno of error that occurred
64 **/
65 void exit_daemon(const char *msg, int error);
66
67 /**
68  * @brief Log at ERR level that the daemon is ready to serve connections
69  *
70  * Optionally report status to systemd if systemd integration is enabled.
71  *
72  * @param[in] daemon Name of daemon to include it message
73 **/
74 void daemon_ready(const char *daemon);
75
76 /**
77  * @brief Log at ERR level the specified daemon status
78  *
79  * For example if it is not ready to serve connections and is waiting
80  * for some event to happen.
81  *
82  * Optionally report status to systemd if systemd integration is enabled.
83  *
84  * @param[in] daemon Name of daemon to include it message
85  * @param[in] msg Message to log
86 **/
87 void daemon_status(const char *daemon, const char *msg);
88
89 #endif /* _BECOME_DAEMON_H */