home *** CD-ROM | disk | FTP | other *** search
- /* Functions to turn a program into a daemon, handle signals, manage
- * a log file facility, and do memory allocation checking.
- *
- * Copyright (c) 1994 Christopher J. Kane.
- *
- * This software is subject to the terms of the MiscKit license
- * agreement. Refer to the license document included with the
- * MiscKit distribution for these terms.
- *
- * Version 1.0 (24 March 1994)
- */
-
- #if !defined(_DAEMON_H)
- #define _DAEMON_H 1
- #include <sys/types.h>
- #include <sys/syslog.h>
-
- #if defined(_AIX)
- #include <sys/select.h>
- #endif
-
- /* Imported variables (must be exported from elsewhere in a program) */
-
- extern int debug;
-
- /* Exported variables */
-
- extern int daemon_pid;
- extern char *daemon_name;
- extern char *daemon_host;
-
- /* Exported functions */
-
- void daemonize(char *prog_name, char *log_fn, int log_facility, char *safe_dir,
- char *lockf_dir, fd_set *ignfds, int loghup_sig, int *ignsigs);
- #define daemon_alloc(SIZE) _daemon_alloc(SIZE, __FILE__, __LINE__)
- #define daemon_free(BLOCK) _daemon_free(BLOCK, __FILE__, __LINE__)
- void daemon_log(int prio, ...);
- void daemon_exit(int exit_val);
-
- /* Exported macros */
-
- #define daemon_assert(E) ((!debug || (E)) ? (void)0 : \
- daemon_log(LOG_DEBUG, "%s:%d: assertion \"" #E "\" failed", \
- __FILE__, __LINE__), daemon_exit(2))
-
- #endif /* _DAEMON_H */
-