home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1995 August / NEBULA.bin / SourceCode / MiscKit1.2.6 / Headers / misckit / Miscdaemon.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-03-23  |  1.3 KB  |  48 lines

  1. /*  Functions to turn a program into a daemon, handle signals, manage
  2.  *  a log file facility, and do memory allocation checking.
  3.  *
  4.  *  Copyright (c) 1994 Christopher J. Kane.
  5.  *
  6.  *  This software is subject to the terms of the MiscKit license
  7.  *  agreement. Refer to the license document included with the
  8.  *  MiscKit distribution for these terms.
  9.  *
  10.  *  Version 1.0 (24 March 1994)
  11.  */
  12.  
  13. #if !defined(_DAEMON_H)
  14. #define _DAEMON_H 1
  15. #include <sys/types.h>
  16. #include <sys/syslog.h>
  17.  
  18. #if defined(_AIX)
  19.     #include <sys/select.h>
  20. #endif
  21.  
  22. /* Imported variables (must be exported from elsewhere in a program) */
  23.  
  24. extern int debug;
  25.  
  26. /* Exported variables */
  27.  
  28. extern int daemon_pid;
  29. extern char *daemon_name;
  30. extern char *daemon_host;
  31.  
  32. /* Exported functions */
  33.  
  34. void daemonize(char *prog_name, char *log_fn, int log_facility, char *safe_dir,
  35.         char *lockf_dir, fd_set *ignfds, int loghup_sig, int *ignsigs);
  36. #define daemon_alloc(SIZE) _daemon_alloc(SIZE, __FILE__, __LINE__)
  37. #define daemon_free(BLOCK) _daemon_free(BLOCK, __FILE__, __LINE__)
  38. void daemon_log(int prio, ...);
  39. void daemon_exit(int exit_val);
  40.  
  41. /* Exported macros */
  42.  
  43. #define daemon_assert(E) ((!debug || (E)) ? (void)0 : \
  44.     daemon_log(LOG_DEBUG, "%s:%d: assertion \"" #E "\" failed", \
  45.     __FILE__, __LINE__), daemon_exit(2))
  46.  
  47. #endif /* _DAEMON_H */
  48.