2 * Copyright (c) 1994, 1995. Netscape Communications Corporation. All
5 * Use of this software is governed by the terms of the license agreement for
6 * the Netscape Communications or Netscape Comemrce Server between the
11 /* ------------------------------------------------------------------------ */
15 * daemon.h: Things related to the accepting connections
25 #include <nt/ntdaemon.h>
31 #include <pwd.h> /* struct passwd */
34 /* ------------------------------- Defines -------------------------------- */
37 #define child_exit exit
40 /* Codes for child_status */
41 #define CHILD_EMPTY_SLOT 0xfe
42 #define CHILD_AWAIT_CONNECT 0xff
43 #define CHILD_PROCESSING 0x00
44 #define CHILD_READING 0x01
45 #define CHILD_WRITING 0x02
46 #define CHILD_RESOLVING 0x03
56 #if defined(DAEMON_UNIX_POOL) || defined(DAEMON_UNIX_MOBRULE)
57 int maxprocs
, minprocs
, proclife
;
64 int secure_session_timeout
;
70 /* ------------------------------ Prototypes ------------------------------ */
73 /* A unique serial number assigned to each child. */
74 extern int child_serial
;
78 * daemon_run accepts whether or not it should detach from its parent process,
79 * and a daemon structure as its arguments. The daemon structure contains
80 * a port number, a root directory to chroot to (can be NULL), a filename to
81 * log the daemon pid to (can be NULL). daemon_run never returns.
83 * child_callback is a function which will be called every time a new
84 * connection is received. Session is a new session ID.
86 * rcback is a function which is a restart function: When SIGHUP is received,
87 * this function will be called. You may give SIG_DFL if you don't want to
88 * support restarting. The rcback will be passed SIGHUP.
90 * pw is the passwd entry to run the daemon as. If the effective user id is
91 * root, daemon_run will try to set its uid and gid to the user pointed
92 * to by this structure. You may pass NULL.
95 void daemon_run(int det
, void (*child_callback
)(Session
*), daemon_s
*d
);
98 * fork is a wrapper for the system's fork function. This closes the listen
99 * socket for the mob. This also makes sure that a threaded daemon only gets
100 * the calling thread and not all of them.
107 * Set status to the given code for statistics reporting
111 void child_status(int code
);
113 #define child_status(code) (void)(code)