  
  - (void)registerForEvents {
    int backlog;
-+  NGActiveSocket *controlSocket;
 +  WOChildMessage message;
 +
 +  controlSocket = [[WOCoreApplication application] controlSocket];
 +  if (controlSocket) {
++    [controlSocket retain];
 +    ASSIGN(self->socket, [[WOCoreApplication application] listeningSocket]);
 +    [[NSNotificationCenter defaultCenter]
 +                         addObserver:self

 - (NSException *)_processCommandParserException:(NSException *)_exception {
   [self logWithFormat:@"ERROR(%s): catched IMAP4 parser exception %@: %@",
 	__PRETTY_FUNCTION__, [_exception name], [_exception reason]];
@@ -1412,21 +1567,24 @@
       return nil;
   }
 

+
+- (void) acceptControlMessage: (NSNotification *) aNotification
+{
+  NGActiveSocket *notificationSocket, *connection;
+  WOChildMessage message;
+  NSAutoreleasePool *pool;
+
+  // NSLog (@"received control message");
+  notificationSocket = [aNotification object];
+  if (notificationSocket == controlSocket) {
+    // [self logWithFormat:@"child accepting message from socket: %@", controlSocket];
+    while (![controlSocket safeReadBytes: &message
+                                   count: sizeof (WOChildMessage)])
+      NSLog (@"renotifying watchdog");
+    if (message == WOChildMessageAccept) {
+      pool = [NSAutoreleasePool new];
+      connection = [self _accept];
+      if ([controlSocket safeWriteBytes: &message
+                                  count: sizeof (WOChildMessage)])
+        ;
+      [self _handleConnection: connection];
+      message = WOChildMessageReady;
+      [controlSocket safeWriteBytes: &message count: sizeof (WOChildMessage)];
+      [pool release];
+    }
+    else if (message == WOChildMessageShutdown) {
+      [controlSocket safeWriteBytes: &message
+                              count: sizeof (WOChildMessage)];
+      [[WOCoreApplication application] terminate];
+    }
+  }
+}
+
