Hi,
The current master doesn't become daemon. The master should run in
background and detach controling terminal. Following patch also fixes
compilation problem under FreeBSD (maybe *BSD).
Index: cyrus-imapd-2.1.2/config.h.in
diff -u cyrus-imapd-2.1.2/config.h.in.orig cyrus-imapd-2.1.2/config.h.in
--- cyrus-imapd-2.1.2/config.h.in.orig Sat Feb 16 05:40:05 2002
+++ cyrus-imapd-2.1.2/config.h.in Thu Feb 28 00:39:47 2002
@@ -173,6 +173,12 @@
/* Define if you have the setrlimit function. */
#undef HAVE_SETRLIMIT
+/* Define if you have the daemon function. */
+#undef HAVE_DAEMON
+
+/* Define if you have the setsid function. */
+#undef HAVE_SETSID
+
/* Define if you have the strcasecmp function. */
#undef HAVE_STRCASECMP
@@ -238,6 +244,7 @@
/* getaddrinfo things */
#include <netdb.h>
+#include <sys/types.h>
#include <sys/socket.h>
#ifndef HAVE_GETADDRINFO
Index: cyrus-imapd-2.1.2/configure.in
diff -u cyrus-imapd-2.1.2/configure.in.orig cyrus-imapd-2.1.2/configure.in
--- cyrus-imapd-2.1.2/configure.in.orig Wed Feb 27 19:08:21 2002
+++ cyrus-imapd-2.1.2/configure.in Wed Feb 27 19:08:43 2002
@@ -177,6 +177,9 @@
AC_CHECK_HEADERS(sys/resource.h)
AC_CHECK_FUNCS(setrlimit)
+dnl for detaching terminal
+AC_CHECK_FUNCS(daemon setsid)
+
AC_EGREP_HEADER(socklen_t, sys/socket.h, AC_DEFINE(HAVE_SOCKLEN_T))
AC_EGREP_HEADER(rlim_t, sys/resource.h, AC_DEFINE(HAVE_RLIM_T))
Index: cyrus-imapd-2.1.2/man/master.8
diff -u cyrus-imapd-2.1.2/man/master.8.orig cyrus-imapd-2.1.2/man/master.8
--- cyrus-imapd-2.1.2/man/master.8.orig Fri May 4 03:49:47 2001
+++ cyrus-imapd-2.1.2/man/master.8 Wed Feb 27 19:18:29 2002
@@ -69,7 +69,8 @@
to increase this value. refer to \fBlisten(2)\fR for details.
.TP
.BI \-D
-Don't close stdin/stdout/stderr. Primiarly useful for debugging.
+Don't close stdin/stdout/stderr, and run in foreground. Primiarly
+useful for debugging.
.SH CONFIGURATION
Upon execution,
.I master
Index: cyrus-imapd-2.1.2/master/master.c
diff -u cyrus-imapd-2.1.2/master/master.c.orig cyrus-imapd-2.1.2/master/master.c
--- cyrus-imapd-2.1.2/master/master.c.orig Thu Feb 14 06:02:54 2002
+++ cyrus-imapd-2.1.2/master/master.c Thu Feb 28 00:54:34 2002
@@ -1067,6 +1067,22 @@
memset(&ctable, 0, sizeof(struct centry *) * child_table_size);
if (close_std) {
+#ifdef HAVE_DAEMON
+ daemon(0, 0);
+#else
+ switch (fork()) {
+ case -1:
+ fatal("couldn't fork: %m", 2);
+ case 0:
+ break;
+ default:
+ exit(EX_OK);
+ }
+#ifdef HAVE_SETSID
+ if (setsid() == -1)
+ fatal("setsid failed: %m", 2);
+#endif
+#endif
/* close stdin/out/err */
for (fd = 0; fd < 3; fd++) {
close(fd);
--
Hajimu UMEMOTO @ Internet Mutual Aid Society Yokohama, Japan
[EMAIL PROTECTED] [EMAIL PROTECTED] ume@{,jp.}FreeBSD.org
http://www.imasy.org/~ume/