Daemon.h
/*
* Copyright (C) 2013 Canonical Ltd
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Authored by: Michi Henning <michi.henning@canonical.com>
*/
#ifndef LOMIRI_UTIL_DAEMON_H
#define LOMIRI_UTIL_DAEMON_H
#include <lomiri/util/DefinesPtrs.h>
#include <lomiri/util/NonCopyable.h>
#include <sys/types.h>
namespace lomiri
{
namespace util
{
namespace internal
{
class DaemonImpl;
}
class LOMIRI_API Daemon final
{
public:
NONCOPYABLE(Daemon);
LOMIRI_DEFINES_PTRS(Daemon);
static UPtr create();
void close_fds() noexcept;
void reset_signals() noexcept;
void set_umask(mode_t mask) noexcept;
void set_working_directory(std::string const& working_directory);
void daemonize_me();
~Daemon() noexcept;
private:
Daemon(); // Class is final, instantiation only via create()
std::unique_ptr<internal::DaemonImpl> p_;
};
} // namespace util
} // namespace lomiri
#endif
DefinesPtrs.h
LOMIRI_DEFINES_PTRS
#define LOMIRI_DEFINES_PTRS(classname)
Macro to add smart pointer definitions to a class.
Definition: DefinesPtrs.h:52
lomiri::util::Daemon
Helper class to turn a process into a daemon.
Definition: Daemon.h:67
lomiri
Top-level namespace for all things Lomiri-related.
Definition: Version.h:38