libdaemon  0.14
dfork.h
Go to the documentation of this file.
1 #ifndef foodaemonforkhfoo
2 #define foodaemonforkhfoo
3 
4 /***
5  This file is part of libdaemon.
6 
7  Copyright 2003-2008 Lennart Poettering
8 
9  libdaemon is free software; you can redistribute it and/or modify
10  it under the terms of the GNU Lesser General Public License as
11  published by the Free Software Foundation, either version 2.1 of the
12  License, or (at your option) any later version.
13 
14  libdaemon is distributed in the hope that it will be useful, but
15  WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  Lesser General Public License for more details.
18 
19  You should have received a copy of the GNU Lesser General Public
20  License along with libdaemon. If not, see
21  <http://www.gnu.org/licenses/>.
22 ***/
23 
24 #include <sys/types.h>
25 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 
63 pid_t daemon_fork(void);
64 
72 
80 void daemon_retval_done(void);
81 
91 int daemon_retval_wait(int timeout);
92 
101 
106 #define DAEMON_CLOSE_ALL_AVAILABLE 1
107 
112 int daemon_close_all(int except_fd, ...);
113 
118 int daemon_close_allv(const int except_fds[]);
119 
124 #define DAEMON_UNBLOCK_SIGS_AVAILABLE 1
125 
130 int daemon_unblock_sigs(int except, ...);
131 
136 int daemon_unblock_sigsv(const int except[]);
137 
142 #define DAEMON_RESET_SIGS_AVAILABLE 1
143 
148 int daemon_reset_sigs(int except, ...);
149 
154 int daemon_reset_sigsv(const int except[]);
155 
156 #ifdef __cplusplus
157 }
158 #endif
159 
160 #endif
daemon_reset_sigsv
int daemon_reset_sigsv(const int except[])
Same as daemon_reset_sigs() but takes an array of signals, terminated by -1.
daemon_retval_send
int daemon_retval_send(int s)
Send the specified integer to the parent process.
daemon_unblock_sigs
int daemon_unblock_sigs(int except,...)
Unblock all signals except those passed.
daemon_reset_sigs
int daemon_reset_sigs(int except,...)
Reset all signal handlers except those passed.
daemon_close_all
int daemon_close_all(int except_fd,...)
Close all file descriptors except those passed.
daemon_retval_done
void daemon_retval_done(void)
Frees the resources allocated by daemon_retval_init().
daemon_close_allv
int daemon_close_allv(const int except_fds[])
Same as daemon_close_all but takes an array of fds, terminated by -1.
daemon_retval_init
int daemon_retval_init(void)
Allocate and initialize resources required by the daemon_retval_xxx() functions.
daemon_unblock_sigsv
int daemon_unblock_sigsv(const int except[])
Same as daemon_unblock_sigs() but takes an array of signals, terminated by -1.
daemon_fork
pid_t daemon_fork(void)
Does a daemonizing fork().
daemon_retval_wait
int daemon_retval_wait(int timeout)
Return the value sent by the child via the daemon_retval_send() function, but wait only the specified...