Daemon.hxx 2.01 KB
Newer Older
1
/*
2
 * Copyright 2003-2018 The Music Player Daemon Project
3 4 5 6 7 8 9 10 11 12 13
 * http://www.musicpd.org
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * 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 General Public License for more details.
14 15 16 17
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 19
 */

Max Kellermann's avatar
Max Kellermann committed
20 21
#ifndef MPD_DAEMON_HXX
#define MPD_DAEMON_HXX
22

23
class AllocatedPath;
24

25
#ifndef _WIN32
26
void
27
daemonize_init(const char *user, const char *group, AllocatedPath &&pidfile);
28 29
#else
static inline void
30
daemonize_init(const char *user, const char *group, AllocatedPath &&pidfile)
31 32
{ (void)user; (void)group; (void)pidfile; }
#endif
33

34
#ifndef _WIN32
35
void
36
daemonize_finish();
37 38
#else
static inline void
39
daemonize_finish()
40 41
{ /* nop */ }
#endif
42

43 44 45 46
/**
 * Kill the MPD which is currently running, pid determined from the
 * pid file.
 */
47
#ifndef _WIN32
48
void
49
daemonize_kill();
50
#else
51
#include <stdexcept>
52
static inline void
53
daemonize_kill()
54
{
55
	throw std::runtime_error("--kill is not available on WIN32");
56
}
57
#endif
58

59 60 61
/**
 * Close stdin (fd 0) and re-open it as /dev/null.
 */
62
#ifndef _WIN32
63
void
64
daemonize_close_stdin();
65 66
#else
static inline void
67
daemonize_close_stdin() {}
68
#endif
69

70 71 72
/**
 * Change to the configured Unix user.
 */
73
#ifndef _WIN32
74
void
75
daemonize_set_user();
76 77
#else
static inline void
78
daemonize_set_user()
79 80
{ /* nop */ }
#endif
81

82
#ifndef _WIN32
83
void
84
daemonize_begin(bool detach);
85 86
#else
static inline void
87
daemonize_begin(bool detach)
88 89
{ (void)detach; }
#endif
90

91
#ifndef _WIN32
92 93 94 95 96 97 98
void
daemonize_commit();
#else
static inline void
daemonize_commit() {}
#endif

99
#endif