Commit | Line | Data |
---|---|---|
99ed9c43 MD |
1 | #ifndef LTTNG_DAEMONIZE_H |
2 | #define LTTNG_DAEMONIZE_H | |
3 | ||
4 | /* | |
5 | * Copyright (C) 2013 - David Goulet <dgoulet@efficios.com> | |
6 | * Copyright (C) 2014 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com> | |
7 | * | |
8 | * This program is free software; you can redistribute it and/or modify it | |
9 | * under the terms of the GNU General Public License, version 2 only, as | |
10 | * published by the Free Software Foundation. | |
11 | * | |
12 | * This program is distributed in the hope that it will be useful, but WITHOUT | |
13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | |
15 | * more details. | |
16 | * | |
17 | * You should have received a copy of the GNU General Public License along with | |
18 | * this program; if not, write to the Free Software Foundation, Inc., 51 | |
19 | * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | |
20 | */ | |
21 | ||
22 | #include <unistd.h> | |
d5d51699 | 23 | #include <common/macros.h> |
99ed9c43 MD |
24 | |
25 | /* | |
26 | * Daemonize this process by forking and making the parent wait for the child | |
27 | * to signal it indicating readiness. Once received, the parent successfully | |
28 | * quits. | |
29 | * | |
30 | * The child process undergoes the same action that daemon(3) does meaning | |
31 | * setsid, chdir, and dup /dev/null into 0, 1 and 2. | |
32 | * | |
33 | * Return 0 on success else -1 on error. | |
34 | */ | |
d5d51699 | 35 | LTTNG_HIDDEN |
99ed9c43 MD |
36 | int lttng_daemonize(pid_t *child_ppid, int *completion_flag, |
37 | int close_fds); | |
38 | ||
39 | #endif /* LTTNG_DAEMONIZE_H */ |