diff -Nru mailutils.cvs/imap4d/imap4d.c mailutils.prod/imap4d/imap4d.c
--- mailutils.cvs/imap4d/imap4d.c	2004-01-15 14:18:35.000000000 +0100
+++ mailutils.prod/imap4d/imap4d.c	2004-04-12 15:46:38.000000000 +0200
@@ -283,13 +283,13 @@
 #ifdef HAVE_SIGACTION
   {
     struct sigaction act;
-    act.sa_handler = imap4d_sigchld;
+    act.sa_handler = mu_deadchld_hanlder;
     sigemptyset (&act.sa_mask);
     act.sa_flags = 0;
     sigaction (SIGCHLD, &act, NULL);
   }
 #else
-  signal (SIGCHLD, imap4d_sigchld);
+  signal (SIGCHLD, mu_deadchld_hanlder);
 #endif
 }
 
@@ -304,6 +304,7 @@
   pid_t pid;
   int listenfd, connfd;
   size_t size;
+  unsigned int children = 0;
 
   listenfd = socket (PF_INET, SOCK_STREAM, 0);
   if (listenfd == -1)
@@ -335,6 +336,8 @@
 
   for (;;)
     {
+      mu_process_cleanup (&children);
+
       if (children > maxchildren)
 	{
 	  syslog (LOG_ERR, _("too many children (%lu)"),
diff -Nru mailutils.cvs/imap4d/imap4d.h mailutils.prod/imap4d/imap4d.h
--- mailutils.cvs/imap4d/imap4d.h	2003-10-06 15:08:50.000000000 +0200
+++ mailutils.prod/imap4d/imap4d.h	2004-04-12 15:45:47.000000000 +0200
@@ -147,7 +147,6 @@
 extern char *homedir;
 extern char *rootdir;
 extern int state;
-extern volatile size_t children;
 extern int is_virtual;
 extern struct daemon_param daemon_param;
 extern struct mu_auth_data *auth_data; 
@@ -208,7 +207,6 @@
 extern size_t uid_to_msgno __P ((size_t));
 
 /* Signal handling.  */
-extern RETSIGTYPE imap4d_sigchld __P ((int));
 extern RETSIGTYPE imap4d_signal __P ((int));
 extern int imap4d_bye __P ((int));
 extern int imap4d_bye0 __P ((int reason, struct imap4d_command *command));
diff -Nru mailutils.cvs/imap4d/signal.c mailutils.prod/imap4d/signal.c
--- mailutils.cvs/imap4d/signal.c	2003-08-29 21:08:41.000000000 +0200
+++ mailutils.prod/imap4d/signal.c	2004-04-12 15:44:38.000000000 +0200
@@ -18,21 +18,6 @@
 #define __USE_MISC
 #include "imap4d.h"
 
-RETSIGTYPE
-imap4d_sigchld (int signo)
-{
-  pid_t pid;
-  int status;
-
-  while ((pid = waitpid (-1, &status, WNOHANG)) > 0)
-    --children;
-#ifndef HAVE_SIGACTION
-  /* On some system, signal implements the unreliable semantic and
-     has to be rearm.  */
-  signal (signo, imap4d_sigchld);
-#endif
-}
-
 /* Default signal handler to call the imap4d_bye() function */
 
 RETSIGTYPE
diff -Nru mailutils.cvs/include/mailutils/mutil.h mailutils.prod/include/mailutils/mutil.h
--- mailutils.cvs/include/mailutils/mutil.h	2004-01-13 16:08:24.000000000 +0100
+++ mailutils.prod/include/mailutils/mutil.h	2004-04-12 15:44:38.000000000 +0200
@@ -18,12 +18,17 @@
 #ifndef _MAILUTILS_MUTIL_H
 #define _MAILUTILS_MUTIL_H
 
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 /*
    Collection of useful utility routines that are worth sharing,
    but don't have a natural home somewhere else.
 */
 
 #include <time.h>
+#include <stdio.h>
 
 #include <mailutils/list.h>
 #include <mailutils/types.h>
@@ -129,6 +134,13 @@
 extern int mu_true_answer_p __P((const char *p));
 extern int mu_scheme_autodetect_p __P((const char *scheme, const char **path));
 
+/* Handler for SIGCHLD, on some system, signal implements the unreliable
+ *  semantic and has to be rearm.  */
+extern RETSIGTYPE mu_deadchld_hanlder __P ((int signo));
+
+/* Wait for dead children and decrement children counter */
+extern void mu_process_cleanup __P ((unsigned int* children));
+
 #ifdef __cplusplus
 }
 #endif
diff -Nru mailutils.cvs/mailbox/mutil.c mailutils.prod/mailbox/mutil.c
--- mailutils.cvs/mailbox/mutil.c	2004-04-10 16:17:39.000000000 +0200
+++ mailutils.prod/mailbox/mutil.c	2004-04-12 15:44:38.000000000 +0200
@@ -15,10 +15,6 @@
    License along with this library; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA  */
 
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif
-
 #include <errno.h>
 #include <limits.h>
 #include <netdb.h>
@@ -1171,3 +1167,23 @@
   return 0;
 }
     
+/* Handler for SIGCHLD, on some system, signal implements the unreliable
+ *  semantic and has to be rearm.  */
+RETSIGTYPE
+mu_deadchld_hanlder (int signo)
+{
+#ifndef HAVE_SIGACTION
+  signal (signo, mu_deadchld_hanlder);
+#endif
+}
+
+/* Wait for dead children and decrement children counter */
+void
+mu_process_cleanup (unsigned int* children)
+{
+  pid_t pid;
+  int status;
+  
+  while ( (pid = waitpid (-1, &status, WNOHANG)) > 0)
+    --*children;
+}
diff -Nru mailutils.cvs/pop3d/pop3d.c mailutils.prod/pop3d/pop3d.c
--- mailutils.cvs/pop3d/pop3d.c	2004-02-08 23:06:36.000000000 +0100
+++ mailutils.prod/pop3d/pop3d.c	2004-04-12 15:46:29.000000000 +0200
@@ -256,13 +256,13 @@
 #ifdef HAVE_SIGACTION
   {
     struct sigaction act;
-    act.sa_handler = pop3d_sigchld;
+    act.sa_handler = mu_deadchld_hanlder;
     sigemptyset (&act.sa_mask);
     act.sa_flags = 0;
     sigaction (SIGCHLD, &act, NULL);
   }
 #else
-  signal (SIGCHLD, pop3d_sigchld);
+  signal (SIGCHLD, mu_deadchld_hanlder);
 #endif
 }
 
@@ -467,6 +467,7 @@
   pid_t pid;
   int listenfd, connfd;
   size_t size;
+  unsigned int children = 0;
 
   listenfd = socket (PF_INET, SOCK_STREAM, 0);
   if (listenfd == -1)
@@ -498,7 +499,7 @@
 
   for (;;)
     {
-      process_cleanup ();
+      mu_process_cleanup (&children);
       if (children > maxchildren)
         {
 	  syslog (LOG_ERR, _("too many children (%lu)"),
diff -Nru mailutils.cvs/pop3d/pop3d.h mailutils.prod/pop3d/pop3d.h
--- mailutils.cvs/pop3d/pop3d.h	2004-01-08 17:31:40.000000000 +0100
+++ mailutils.prod/pop3d/pop3d.h	2004-04-12 15:44:38.000000000 +0200
@@ -202,7 +202,6 @@
 extern char *username;
 extern char *maildir;
 extern char *md5shared;
-extern volatile size_t children;
 extern struct daemon_param daemon_param;
 extern int debug_mode;
 #ifdef WITH_TLS
@@ -226,7 +225,6 @@
 extern int pop3d_quit           __P ((const char *));
 extern int pop3d_retr           __P ((const char *));
 extern int pop3d_rset           __P ((const char *));
-extern void process_cleanup     __P ((void));
 
 extern RETSIGTYPE pop3d_sigchld __P ((int));
 extern RETSIGTYPE pop3d_signal  __P ((int));
diff -Nru mailutils.cvs/pop3d/signal.c mailutils.prod/pop3d/signal.c
--- mailutils.cvs/pop3d/signal.c	2003-09-18 12:06:36.000000000 +0200
+++ mailutils.prod/pop3d/signal.c	2004-04-12 15:44:38.000000000 +0200
@@ -17,31 +17,6 @@
 
 #include "pop3d.h"
 
-static int need_cleanup = 0;
-
-void
-process_cleanup ()
-{
-  pid_t pid;
-  int status;
-  
-  if (need_cleanup)
-    {
-      need_cleanup = 0;
-      while ( (pid = waitpid (-1, &status, WNOHANG)) > 0)
-	--children;
-    }
-}
-
-RETSIGTYPE
-pop3d_sigchld (int signo ARG_UNUSED)
-{
-  need_cleanup = 1;
-#ifndef HAVE_SIGACTION
-  signal (signo, pop3d_sigchld);
-#endif
-}
-
 /* Default signal handler to call the pop3d_abquit() function */
 
 RETSIGTYPE
