00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00056 #ifndef __LIBSB_DAEMONIZE_H__
00057 #define __LIBSB_DAEMONIZE_H__
00058
00059
00060 #ifdef HAVE_CONFIG_H
00061 # include <config.h>
00062 #endif
00063
00064
00065 #include <sys/types.h>
00066 #include <sys/stat.h>
00067 #include <unistd.h>
00068 #include <signal.h>
00069 #include <stdlib.h>
00070
00071
00072 #if defined(__cplusplus)
00073 extern "C" {
00074 #endif
00075
00076
00077
00079 #define MAX_PIDDATA_LENGTH 16
00080
00081
00082
00094 int sb_daemon_drop_privileges(void);
00095
00096
00097
00106 int sb_daemon_no_corefile(void);
00107
00108
00109
00120 int sb_daemon_is_started_by_init(void);
00121
00122
00123
00133 int sb_daemon_is_started_by_inetd(void);
00134
00135
00136
00144 int sb_daemon_is_started_by_root(void);
00145
00146
00147
00157 int sb_daemon_is_started_suid(void);
00158
00159
00160
00172 int sb_daemon_create_fd(int fd, int mode);
00173
00174
00175
00188 int sb_daemon_change_user(uid_t uid, gid_t gid);
00189
00190
00191
00200 int sb_daemon_detach(const char *rundir);
00201
00202
00203
00211 int sb_daemon_init(const char *name,
00212 const char *rundir,
00213 const char *pidfile);
00214
00215
00216
00222 int sb_daemon_is_running(const char *pidfile);
00223
00224
00225
00231 int sb_daemon_destroy(const char *pidfile);
00232
00233
00234
00243 int sb_daemon_pidfile_create_and_lock(const char *pidfile);
00244
00245
00246
00252 int sb_daemon_pidfile_write(int fd);
00253
00254
00255
00261 pid_t sb_daemon_pidfile_read(const char *pidfile);
00262
00263
00264
00265 #if defined(__cplusplus)
00266 }
00267 #endif
00268
00269 #endif
00270
00271