s3: tests: Add new test_stream_dir_rename.sh test.
[Samba.git] / lib / util / become_daemon.h
blobe12be27246bfd8b204ad7c65cfa538600ad50ec1
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 Enable or disable daemon status systemd notifications
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.
43 * @param[in] enable True to enable notifications, false to disable
44 **/
45 void daemon_sd_notifications(bool enable);
47 /**
48 * @brief Become a daemon, optionally discarding the controlling terminal
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);
56 /**
57 * @brief Exit daemon and log an error message at ERR level
59 * Optionally report failure to systemd if systemd integration is
60 * enabled.
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);
67 /**
68 * @brief Log at ERR level that the daemon is ready to serve connections
70 * Optionally report status to systemd if systemd integration is enabled.
72 * @param[in] daemon Name of daemon to include it message
73 **/
74 void daemon_ready(const char *daemon);
76 /**
77 * @brief Log at ERR level the specified daemon status
79 * For example if it is not ready to serve connections and is waiting
80 * for some event to happen.
82 * Optionally report status to systemd if systemd integration is enabled.
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);
89 #endif /* _BECOME_DAEMON_H */