My Project
Loading...
Searching...
No Matches
Daemon.h
1/*
2 * Copyright (C) 2013 Canonical Ltd
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Michi Henning <michi.henning@canonical.com>
17 */
18
19#ifndef UNITY_UTIL_DAEMON_H
20#define UNITY_UTIL_DAEMON_H
21
23#include <unity/util/NonCopyable.h>
24
25#include <sys/types.h>
26
27namespace unity
28{
29
30namespace util
31{
32
33namespace internal
34{
35class DaemonImpl;
36}
37
66class UNITY_API Daemon final
67{
68public:
70 NONCOPYABLE(Daemon);
73
78 static UPtr create();
79
84 void close_fds() noexcept;
85
89 void reset_signals() noexcept;
90
95 void set_umask(mode_t mask) noexcept;
96
105 void set_working_directory(std::string const& working_directory);
106
120 void daemonize_me();
121
122 ~Daemon() noexcept;
123
124private:
125 Daemon(); // Class is final, instantiation only via create()
126
127 std::unique_ptr<internal::DaemonImpl> p_;
128};
129
130} // namespace util
131
132} // namespace unity
133
134#endif
#define UNITY_DEFINES_PTRS(classname)
Macro to add smart pointer definitions to a class.
Definition: DefinesPtrs.h:52
Helper class to turn a process into a daemon.
Definition: Daemon.h:67
Top-level namespace for all things Unity-related.
Definition: Version.h:38