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> | |
23 | ||
24 | /* | |
25 | * Daemonize this process by forking and making the parent wait for the child | |
26 | * to signal it indicating readiness. Once received, the parent successfully | |
27 | * quits. | |
28 | * | |
29 | * The child process undergoes the same action that daemon(3) does meaning | |
30 | * setsid, chdir, and dup /dev/null into 0, 1 and 2. | |
31 | * | |
32 | * Return 0 on success else -1 on error. | |
33 | */ | |
34 | int lttng_daemonize(pid_t *child_ppid, int *completion_flag, | |
35 | int close_fds); | |
36 | ||
37 | #endif /* LTTNG_DAEMONIZE_H */ |