Commit | Line | Data |
---|---|---|
99ed9c43 MD |
1 | #ifndef LTTNG_DAEMONIZE_H |
2 | #define LTTNG_DAEMONIZE_H | |
3 | ||
4 | /* | |
ab5be9fa MJ |
5 | * Copyright (C) 2013 David Goulet <dgoulet@efficios.com> |
6 | * Copyright (C) 2014 Mathieu Desnoyers <mathieu.desnoyers@efficios.com> | |
99ed9c43 | 7 | * |
ab5be9fa | 8 | * SPDX-License-Identifier: GPL-2.0-only |
99ed9c43 | 9 | * |
99ed9c43 MD |
10 | */ |
11 | ||
c9e313bc | 12 | #include <common/macros.hpp> |
99ed9c43 | 13 | |
28f23191 JG |
14 | #include <unistd.h> |
15 | ||
99ed9c43 MD |
16 | /* |
17 | * Daemonize this process by forking and making the parent wait for the child | |
18 | * to signal it indicating readiness. Once received, the parent successfully | |
19 | * quits. | |
20 | * | |
21 | * The child process undergoes the same action that daemon(3) does meaning | |
22 | * setsid, chdir, and dup /dev/null into 0, 1 and 2. | |
23 | * | |
24 | * Return 0 on success else -1 on error. | |
25 | */ | |
28f23191 | 26 | int lttng_daemonize(pid_t *child_ppid, int *completion_flag, int close_fds); |
99ed9c43 MD |
27 | |
28 | #endif /* LTTNG_DAEMONIZE_H */ |